<?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::table('collections', function (Blueprint $table): void {
            $table->string('experiment_treatment', 80)->nullable()->after('experiment_key');
            $table->string('placement_variant', 80)->nullable()->after('experiment_treatment');
            $table->string('ranking_mode_variant', 80)->nullable()->after('placement_variant');
            $table->string('collection_pool_version', 80)->nullable()->after('ranking_mode_variant');
            $table->string('test_label', 120)->nullable()->after('collection_pool_version');

            $table->index(['experiment_key', 'experiment_treatment'], 'collections_experiment_treatment_idx');
            $table->index(['placement_variant', 'ranking_mode_variant'], 'collections_experiment_variants_idx');
        });
    }

    public function down(): void
    {
        Schema::table('collections', function (Blueprint $table): void {
            $table->dropIndex('collections_experiment_treatment_idx');
            $table->dropIndex('collections_experiment_variants_idx');
            $table->dropColumn([
                'experiment_treatment',
                'placement_variant',
                'ranking_mode_variant',
                'collection_pool_version',
                'test_label',
            ]);
        });
    }
};