-- +goose Up ALTER TABLE game_exports ADD COLUMN released_at TIMESTAMPTZ; DROP INDEX game_exports_active; CREATE UNIQUE INDEX game_exports_active ON game_exports(game_id) WHERE state IN ('preparing', 'ready') AND released_at IS NULL; -- +goose Down -- Refuse rollback if retained ready exports cannot fit the old unique index. DROP INDEX game_exports_active; CREATE UNIQUE INDEX game_exports_active ON game_exports(game_id) WHERE state IN ('preparing', 'ready'); ALTER TABLE game_exports DROP COLUMN released_at;