<?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('kuesioner', function (Blueprint $table) {
            $table->id('KuesionerId');
            $table->integer('ms_sekolah_id');
            $table->string('npsn')->nullable();
            $table->integer('level')->default(0);
            $table->integer('tim_adiwiyata')->default(0);
            $table->integer('info_pblhs')->default(0);
            $table->json('media')->nullable();
            $table->json('materi')->nullable();
            $table->json('komitmen')->nullable();
            $table->json('kegiatan_lingkungan')->nullable();
            $table->json('pihak_kegiatan_lingkungan')->nullable();
            $table->year('tahun')->nullable();
            $table->year('tahun_penghargaan')->nullable();
            $table->text('link_sk_adiwiyata')->nullable();
            $table->integer('created_by');
            $table->timestampsTz();

            $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('kuesioners');
    }
};
