| 1 | BEGIN; |
| 2 | |
| 3 | DROP TABLE risk_decisions; |
| 4 | DROP INDEX transfers_paid_idx; |
| 5 | |
| 6 | DROP INDEX transfers_due_idx; |
| 7 | CREATE INDEX transfers_due_idx ON transfers (next_attempt_at) |
| 8 | WHERE state IN ('pending', 'funds_held', 'compensating'); |
| 9 | |
| 10 | ALTER TABLE transfers DROP CONSTRAINT transfers_state_check; |
| 11 | ALTER TABLE transfers ADD CONSTRAINT transfers_state_check CHECK (state IN |
| 12 | ('pending', 'funds_held', 'completed', 'compensating', 'failed', 'reversed')); |
| 13 | |
| 14 | COMMIT; |