<?php

use App\Models\Category;
use App\Models\Group;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class ChangeTranslatableColumns extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::disableForeignKeyConstraints();

        Category::truncate();
        Group::truncate();

        Schema::table('categories', function (Blueprint $table) {
            $table->json('title')->change();
        });

        Schema::table('groups', function (Blueprint $table) {
            $table->json('title')->change();
            $table->json('file')->change();
        });

        Schema::enableForeignKeyConstraints();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('categories', function (Blueprint $table) {
            $table->string('title')->change();
        });

        Schema::table('groups', function (Blueprint $table) {
            $table->string('title')->change();
            $table->string('file')->change();
        });
    }
}
