<?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('campaigns', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug')->unique();
            $table->string('assessment')->default('financial-health'); // assessment slug this campaign links to
            $table->string('headline')->nullable();                    // optional custom intro headline
            $table->text('intro')->nullable();                         // optional custom intro copy
            $table->boolean('is_active')->default(true);
            $table->unsignedInteger('leads_count')->default(0);
            $table->timestamps();
        });

        Schema::table('assessment_attempts', function (Blueprint $table) {
            $table->string('campaign')->nullable()->after('guest_email');
        });
    }

    public function down(): void
    {
        Schema::table('assessment_attempts', function (Blueprint $table) {
            $table->dropColumn('campaign');
        });
        Schema::dropIfExists('campaigns');
    }
};
