<?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::create('dokumen_administrasi', function (Blueprint $table) {
            $table->id('DokumenAdministrasiId');
            $table->integer('kuesioner_id');
            $table->integer('ms_sekolah_id');
            $table->integer('npsn');
            $table->integer('created_by');
            $table->text('link')->nullable();
            $table->year('tahun');
            $table->integer('status')->default(0);
            $table->timestampsTz();

            $table->foreign('kuesioner_id')->references('KuesionerId')->on('kuesioner')->onDelete('cascade');
            $table->foreign('ms_sekolah_id')->references('MsSekolahId')->on('ms_sekolah')->onDelete('cascade');
            $table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');
        });
    }

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