<?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('materis', function (Blueprint $table) {
            $table->id('id_materi');
            $table->unsignedBigInteger('id_mengajar');
            $table->string('judul_materi', 200);
            $table->string('lampiran_materi')->nullable();
            $table->text('deskripsi')->nullable();
            $table->timestamp('tanggal_upload')->useCurrent();
            $table->timestamps();

            $table->foreign('id_mengajar')
                  ->references('id_mengajar')
                  ->on('mengajars')
                  ->onDelete('cascade');
        });
    }

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