<?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('kelas', function (Blueprint $table) {
            $table->id(); // This creates an auto-incrementing ID
            $table->foreignId('sekolah_id')->constrained()->onDelete('cascade'); // Assumes 'sekolahs' table exists and has an 'id' column
            $table->string('nama_kelas');
            $table->timestamps(); // Creates 'created_at' and 'updated_at' timestamps

            $table->unique(['nama_kelas', 'sekolah_id']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('kelas'); // Drops the 'kelas' table if the migration is rolled back
    }
};
