<?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('notification_logs', function (Blueprint $table) {
            $table->timestamp('scheduled_at')->nullable()->after('sent_at');
            $table->text('subject')->nullable()->after('message');
            $table->text('wa_message')->nullable()->after('subject');
            $table->string('recipient_name')->nullable()->after('wa_message');
            $table->string('recipient_contact')->nullable()->after('recipient_name');
            $table->index(['status', 'scheduled_at']);
        });
    }

    public function down(): void
    {
        Schema::table('notification_logs', function (Blueprint $table) {
            $table->dropIndex(['status', 'scheduled_at']);
            $table->dropColumn(['scheduled_at', 'subject', 'wa_message', 'recipient_name', 'recipient_contact']);
        });
    }
};
