<?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_log', function (Blueprint $table) {
            $table->id('KuesionerLogId');
            $table->integer('kuesioner_id');
            $table->integer('ms_sekolah_id');
            $table->integer('npsn');
            $table->integer('ms_group_id');
            $table->string('step')->nullable();
            $table->text('note')->nullable();
            $table->integer('status');
            $table->integer('created_by');
            $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('ms_group_id')->references('MsGroupId')->on('ms_group')->onDelete('cascade');
            $table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');
        });
    }

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