<?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::create('ad_sets', function (Blueprint $table) {
            $table->id();
            $table->foreignId('ad_campaign_id')->constrained('ad_campaigns')->onDelete('cascade');
            $table->string('meta_adset_id')->nullable();
            $table->string('name');
            $table->string('budget_type'); // daily, lifetime
            $table->decimal('budget_amount', 10, 2);
            $table->dateTime('start_date');
            $table->dateTime('end_date')->nullable();
            $table->string('country');
            $table->string('city')->nullable();
            $table->integer('age_min');
            $table->integer('age_max');
            $table->string('gender'); // all, male, female
            $table->json('interests')->nullable();
            $table->string('placements_type')->default('automatic'); // automatic, manual
            $table->json('placements')->nullable(); // JSON array for manual placements
            $table->string('status')->default('draft'); // draft, active, paused, archived
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('ad_sets');
    }
};
