<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('campaigns', function (Blueprint $table) {
            $table->string('send_mode', 20)->default('now')->after('scheduled_at'); // now | schedule | range
            $table->timestamp('range_start')->nullable()->after('send_mode');
            $table->timestamp('range_end')->nullable()->after('range_start');
            $table->unsignedInteger('emails_sent')->default(0)->after('range_end');
            $table->unsignedInteger('emails_failed')->default(0)->after('emails_sent');
        });
    }

    public function down(): void
    {
        Schema::table('campaigns', function (Blueprint $table) {
            $table->dropColumn(['send_mode', 'range_start', 'range_end', 'emails_sent', 'emails_failed']);
        });
    }
};
