<?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('mengajars', function (Blueprint $table) {
            $table->id('id_mengajar');
            $table->string('nip', 30);
            $table->string('id_mapel', 20);
            $table->string('id_kelas', 20);
            $table->timestamps();

            $table->foreign('nip')
                  ->references('nip')
                  ->on('gurus')
                  ->onDelete('cascade');
            
            $table->foreign('id_mapel')
                  ->references('id_mapel')
                  ->on('mapels')
                  ->onDelete('cascade');
            
            $table->foreign('id_kelas')
                  ->references('id_kelas')
                  ->on('kelas')
                  ->onDelete('cascade');
        });
    }

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