<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::create('kelas', function (Blueprint $table) {
            $table->id();
            $table->string('nama');
            $table->enum('fase', ['A', 'B', 'C'])->default('A');
            $table->unsignedTinyInteger('tingkat')->default(1);
            $table->string('rombel')->nullable();
            $table->unsignedBigInteger('walikelas_id')->nullable();
            $table->timestamps();

            $table->foreign('walikelas_id')->references('id')->on('users')->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::table('kelas', function (Blueprint $table) {
            $table->dropForeign(['walikelas_id']);
        });
        Schema::dropIfExists('kelas');
    }
};
