<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('sections', function (Blueprint $table) {
            $table->foreignId('division_id')->after('number')->nullable();
        });

        Schema::table('chapters', function (Blueprint $table) {
            $table->foreignId('division_id')->after('number')->nullable();
        });


        Schema::table('parts', function (Blueprint $table) {
            $table->foreignId('division_id')->after('number')->nullable();
        });


        Schema::table('gates', function (Blueprint $table) {
            $table->foreignId('division_id')->after('number')->nullable();
        });

        Schema::table('art', function (Blueprint $table) {
            $table->foreignId('division_id')->after('number')->nullable();
            $table->foreignId('branch_id')->after('number')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('sections', function (Blueprint $table) {
            $table->dropColumn('division_id');
        });

        Schema::table('chapters', function (Blueprint $table) {
            $table->dropColumn('division_id');
        });
        Schema::table('parts', function (Blueprint $table) {
            $table->dropColumn('division_id');
        });
        Schema::table('gates', function (Blueprint $table) {
            $table->dropColumn('division_id');
        });
        Schema::table('branches', function (Blueprint $table) {
            $table->dropColumn('division_id');
        });
        Schema::table('art', function (Blueprint $table) {
            $table->dropColumn('division_id');
            $table->dropColumn('branch_id');
        });
    }
};
