<?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('penilaian_file', function (Blueprint $table) {
            $table->id('PenilaianFileId');
            $table->integer('kuesioner_id');
            $table->integer('ms_sekolah_id');
            $table->string('key')->nullable();
            $table->string('key_option')->nullable();
            $table->integer('page_number');
            $table->text('value')->nullable();
            $table->year('tahun')->nullable();
            $table->integer('created_by');
            $table->timestampsTz();
            $table->softdeletesTz();

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

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