<?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('JadwalSidang', function (Blueprint $table) {
            $table->unsignedBigInteger('PerusahaanID')->after('JadwalSidangID');
            $table->index(['PerusahaanID'], 'IX_Jadwal_PerusahaanID');
            $table->foreign('PerusahaanID')
                ->references('PerusahaanID')
                ->on('Perusahaan')
                ->cascadeOnUpdate()
                ->restrictOnDelete();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('JadwalSidang', function (Blueprint $table) {
            $table->dropForeign(['PerusahaanID']);
            $table->dropIndex('IX_Jadwal_PerusahaanID');
            $table->dropColumn('PerusahaanID');
        });
    }
};

