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_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');
    }
};