File: /home/xedaptot/be.naniguide.com/database/migrations/2026_04_11_100001_create_ad_templates_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_templates', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('uid', 32)->unique();
$table->integer('customer_id')->unsigned()->nullable(); // NULL = system template
$table->string('name', 255);
$table->string('platform', 20)->nullable(); // meta | google | tiktok | linkedin | universal
$table->string('format', 30); // image | video | carousel | story | feed
$table->string('thumbnail_url', 2048)->nullable();
$table->json('content')->nullable(); // BuilderJS JSON
$table->string('category', 100)->nullable();
$table->boolean('is_featured')->default(false);
$table->integer('use_count')->default(0);
$table->timestamps();
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
$table->index(['customer_id', 'platform'], 'idx_adtemplate_customer_platform');
});
}
public function down(): void
{
Schema::dropIfExists('ad_templates');
}
};