<?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::table('detail_test', function (Blueprint $table) {
            $table->dropForeign(['id_test']);
            $table->dropColumn('id_test');
            $table->char('id_test_sessions', 36)->after('id_soal');
            $table->foreign('id_test_sessions')->references('id_test_sessions')->on('test_sessions')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('detail_test', function (Blueprint $table) {
            $table->dropForeign(['id_test_sessions']);
            $table->dropColumn('id_test_sessions');
            $table->unsignedBigInteger('id_test')->after('id_soal');
            $table->foreign('id_test')->references('id_test')->on('test')->onDelete('cascade');
        });
    }
};
