<?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('sms_templates', function (Blueprint $table) {
            $table->boolean('allow_custom_body')->default(false)->after('content');
            $table->foreignId('action_id')->nullable()->after('default_sender_id')->constrained('actions')->nullOnDelete();
            $table->foreignId('decision_id')->nullable()->after('action_id')->constrained('decisions')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('sms_templates', function (Blueprint $table) {
            $table->dropConstrainedForeignId('decision_id');
            $table->dropConstrainedForeignId('action_id');
            $table->dropColumn('allow_custom_body');
        });
    }
};
