<?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_messages', function (Blueprint $table) {
            $table->timestamp('scheduled_at')->nullable()->after('status')->index();
            $table->timestamp('queued_at')->nullable()->after('scheduled_at');
            $table->string('source', 50)->default('manual')->after('message')->index();
        });
    }

    public function down(): void
    {
        Schema::table('sms_messages', function (Blueprint $table) {
            $table->dropIndex(['scheduled_at']);
            $table->dropIndex(['source']);
            $table->dropColumn(['scheduled_at', 'queued_at', 'source']);
        });
    }
};
