<?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('institutions', function(Blueprint $table) {
            $table->foreignId('solicitor_id')->after('id')->default(1)->constrained('solicitors');
        });

        Schema::table('institution_types', function(Blueprint $table) {
            $table->foreignId('solicitor_id')->after('id')->default(1)->constrained('solicitors');
        });

        Schema::table('institution_aliases', function(Blueprint $table) {
            $table->foreignId('solicitor_id')->after('id')->default(1)->constrained('solicitors');
        });

        Schema::table('dsar_types', function(Blueprint $table) {
            $table->foreignId('solicitor_id')->after('id')->default(1)->constrained('solicitors');
        });
    }

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

        Schema::table('institution_contacts', function(Blueprint $table) {
            $table->dropForeign('institutions_solicitor_id_foreign');
        });
    }
};
