<?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('postulations', function (Blueprint $table) {
            $table->string('status')->default('active')->after('photos');
            $table->unsignedBigInteger('related_postulation_id')->nullable()->after('status');
            $table->foreign('related_postulation_id')
                  ->references('id')->on('postulations')
                  ->onDelete('set null');
        });
    }

    public function down(): void
    {
        Schema::table('postulations', function (Blueprint $table) {
            $table->dropForeign(['related_postulation_id']);
            $table->dropColumn(['status', 'related_postulation_id']);
        });
    }
};
