<?php

declare(strict_types=1);

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('collection_surface_definitions', function (Blueprint $table): void {
            $table->timestamp('starts_at')->nullable()->after('is_active');
            $table->timestamp('ends_at')->nullable()->after('starts_at');
            $table->string('fallback_surface_key', 120)->nullable()->after('ends_at');

            $table->index('starts_at');
            $table->index('ends_at');
            $table->index('fallback_surface_key');
        });
    }

    public function down(): void
    {
        Schema::table('collection_surface_definitions', function (Blueprint $table): void {
            $table->dropIndex(['starts_at']);
            $table->dropIndex(['ends_at']);
            $table->dropIndex(['fallback_surface_key']);
            $table->dropColumn(['starts_at', 'ends_at', 'fallback_surface_key']);
        });
    }
};
