File: /home/xedaptot/be.naniguide.com/database/migrations/2026_03_28_000001_create_ab_tests_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('ab_tests', function (Blueprint $table) {
$table->id();
$table->string('uid', 32)->unique();
$table->unsignedInteger('campaign_id');
$table->string('status', 20)->default('draft'); // draft | running | completed | cancelled
$table->string('winner_criteria', 20)->default('open_rate'); // open_rate | click_rate | manual
$table->unsignedBigInteger('winner_variant_id')->nullable();
$table->unsignedTinyInteger('test_percentage')->default(100); // % of list used for test (remainder gets winner)
$table->unsignedSmallInteger('winner_wait_hours')->nullable(); // null = manual winner selection
$table->timestamp('winner_sent_at')->nullable();
$table->timestamps();
$table->foreign('campaign_id')->references('id')->on('campaigns')->onDelete('cascade');
});
}
public function down(): void
{
Schema::dropIfExists('ab_tests');
}
};