<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('JadwalSidang', function (Blueprint $table) {
            $table->id('JadwalSidangID');
            $table->string('NamaKegiatan');
            // FK ke master DokumenType
            $table->unsignedBigInteger('DokumenTypeID');
            $table->text('Deskripsi')->nullable();
            $table->dateTime('TanggalMulai');
            $table->dateTime('TanggalSelesai');
            $table->timestamps();

            $table->index(['DokumenTypeID'], 'IX_Jadwal_DokumenTypeID');
            $table->index(['TanggalMulai'], 'IX_Jadwal_TanggalMulai');
            $table->index(['TanggalMulai', 'TanggalSelesai'], 'IX_Jadwal_TanggalRange');

            $table->foreign('DokumenTypeID')
                ->references('DokumenTypeID')
                ->on('DokumenType')
                ->cascadeOnUpdate()
                ->restrictOnDelete();
        });

    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('JadwalSidang');
    }
};
