<?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::table('interviews', function (Blueprint $table) {
            // Foreign key constraint'i kaldır, sonra nullable yap, sonra yeniden ekle
            $table->dropForeign(['job_application_id']);
            $table->foreignId('job_application_id')->nullable()->change();
            $table->foreign('job_application_id')->references('id')->on('job_applications')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('interviews', function (Blueprint $table) {
            $table->dropForeign(['job_application_id']);
            $table->foreignId('job_application_id')->nullable(false)->change();
            $table->foreign('job_application_id')->references('id')->on('job_applications')->cascadeOnDelete();
        });
    }
};