<?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::table('tema', function (Blueprint $table) {
            $table->unsignedBigInteger('periode_id')->nullable()->after('nama');

            // kalau tabel periode sudah ada
            $table->foreign('periode_id')->references('id')->on('periode')->onDelete('cascade');
        });
    }

    public function down()
    {
        Schema::table('tema', function (Blueprint $table) {
            $table->dropForeign(['periode_id']);
            $table->dropColumn('periode_id');
        });
    }
};
