<?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_profiles', function (Blueprint $table): void {
            $table->id();
            $table->uuid('uuid')->unique();
            $table->string('name');
            $table->boolean('active')->default(true);
            // Credentials
            $table->string('api_username');
            $table->text('encrypted_api_password')->nullable();
            // Defaults and settings
            $table->unsignedBigInteger('default_sender_id')->nullable(); // no FK to avoid circular dep with sms_senders
            $table->json('settings')->nullable();
            $table->timestamps();

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

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