-- Restore migration 022's wider index (which also covered soft-deleted rows). -- -- Note this can FAIL where the up-migration succeeded: once retries-after-delete have been -- allowed, two rows may legitimately share a `client_upload_id` (one deleted, one live), and -- the wider unique index cannot be rebuilt over them. That is inherent to reverting this -- direction, not a defect in the down-migration. If it fails, the live-only index is still -- correct and should simply be kept. DROP INDEX IF EXISTS upload_client_upload_id_key; CREATE UNIQUE INDEX upload_client_upload_id_key ON upload (client_upload_id) WHERE client_upload_id IS NOT NULL;