<?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::create('sms_templates', function (Blueprint $table): void {
            $table->id();
            $table->uuid('uuid')->unique();
            $table->string('name');
            $table->string('slug')->unique();
            $table->text('content');
            $table->json('variables_json')->nullable();
            $table->boolean('is_active')->default(true);
            $table->foreignId('default_profile_id')->nullable()->constrained('sms_profiles')->nullOnDelete();
            $table->foreignId('default_sender_id')->nullable()->constrained('sms_senders')->nullOnDelete();
            $table->timestamps();

            $table->index(['is_active']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('sms_templates');
    }
};
