HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/be.naniguide.com/database/migrations/2026_04_10_200008_create_ad_audiences_table.php
<?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('ad_audiences', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('uid', 32)->unique();
            $table->integer('customer_id')->unsigned();
            $table->string('name', 255);
            $table->string('type', 20);                               // custom | lookalike | saved
            $table->string('source_type', 30)->nullable();            // mail_list | segment | manual
            $table->integer('source_id')->unsigned()->nullable();     // mail_list_id or segment_id
            $table->string('platform', 20)->nullable();               // meta | google | tiktok | linkedin
            $table->string('platform_audience_id', 255)->nullable();
            $table->bigInteger('size_estimate')->nullable();
            $table->string('status', 20)->default('draft');           // draft | syncing | synced | error | stale
            $table->string('sync_status', 20)->default('pending');    // pending | in_progress | completed | failed
            $table->timestamp('last_synced_at')->nullable();
            $table->json('settings')->nullable();                     // lookalike %, country, etc.
            $table->text('sync_error')->nullable();
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
            $table->index(['customer_id', 'type'], 'idx_adaudience_customer_type');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('ad_audiences');
    }
};