<?php

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

/**
 * Which pixel event the ad set optimises toward.
 *
 * It was inferred from the objective alone and never asked: leads meant LEAD
 * whether or not the pixel had ever seen a Lead. Campaign 120252047635070626 is
 * live against a pixel that fires PageView and Subscribe, asking Meta to
 * optimise toward an event it can never observe, and every number on it will
 * look like underdelivery rather than a mismatch.
 *
 * Nullable, because the objective's default is still the answer when nobody
 * chose otherwise, and because every existing campaign was published that way.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('campaigns', function (Blueprint $table) {
            $table->string('conversion_event')->nullable()->after('pixel_id');
        });
    }

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