<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('mata_pelajaran', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tingkat_sekolah_id')->constrained('tingkat_sekolah')->cascadeOnDelete();
            $table->string('nama');
            $table->string('kode', 20);
            $table->timestamps();

            $table->index('tingkat_sekolah_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('mata_pelajaran');
    }
};
