<?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', function (Blueprint $table) {
            $table->id('PenilaianId');
            $table->integer('ms_sekolah_id');
            $table->string('npsn');
            // $table->integer('ms_form_kriteria_id');
            $table->string('key')->nullable();
            $table->integer('page_number');
            $table->json('value')->nullable();
            $table->integer('skor')->default(0);
            $table->integer('status')->nullable();
            $table->integer('level_adiwiyata')->default(0);
            $table->year('tahun')->nullable();
            $table->integer('created_by');
            $table->timestamps();

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

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