<?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('email_templates', function (Blueprint $table): void {
            $table->foreignId('action_id')->nullable()->after('active')->constrained('actions')->nullOnDelete();
            $table->foreignId('decision_id')->nullable()->after('action_id')->constrained('decisions')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('email_templates', function (Blueprint $table): void {
            $table->dropForeign(['action_id']);
            $table->dropForeign(['decision_id']);
            $table->dropColumn(['action_id', 'decision_id']);
        });
    }
};
