<?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('ad_campaigns', function (Blueprint $table) {
            $table->string('meta_campaign_id')->nullable()->after('post_id');
            $table->string('meta_adset_id')->nullable()->after('meta_campaign_id');
            $table->string('meta_creative_id')->nullable()->after('meta_adset_id');
            $table->string('meta_ad_id')->nullable()->after('meta_creative_id');
            $table->string('launch_status')->nullable()->after('meta_ad_id'); // pending, processing, launched, failed
            $table->text('sync_error')->nullable()->after('launch_status');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('ad_campaigns', function (Blueprint $table) {
            $table->dropColumn([
                'meta_campaign_id',
                'meta_adset_id',
                'meta_creative_id',
                'meta_ad_id',
                'launch_status',
                'sync_error',
            ]);
        });
    }
};
