<?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('collection_members', function (Blueprint $table): void {
            $table->timestamp('expires_at')->nullable()->after('invited_at');
            $table->index('expires_at', 'collection_members_expires_at_idx');
        });
    }

    public function down(): void
    {
        Schema::table('collection_members', function (Blueprint $table): void {
            $table->dropIndex('collection_members_expires_at_idx');
            $table->dropColumn('expires_at');
        });
    }
};
