Skip to main content

max / makenotwork

853 B · 19 lines History Blame Raw
1 -- Code fuzz fixes (Run 19, 2026-05-03)
2
3 -- Fix: create_free_guest_transaction ON CONFLICT targeted 'pending' but INSERT
4 -- creates 'completed' rows. Add a matching index and drop the mismatched one.
5 DROP INDEX IF EXISTS idx_transactions_pending_guest_item;
6
7 CREATE UNIQUE INDEX idx_transactions_completed_guest_item
8 ON transactions(guest_email, item_id)
9 WHERE status = 'completed' AND guest_email IS NOT NULL;
10
11 -- Fix: claim_free_project uses bare ON CONFLICT DO NOTHING without specifying
12 -- a target. Add the missing partial unique index so it works correctly.
13 CREATE UNIQUE INDEX IF NOT EXISTS idx_transactions_completed_buyer_project
14 ON transactions(buyer_id, project_id)
15 WHERE status = 'completed' AND project_id IS NOT NULL;
16
17 -- Fix: get_bundle_items should exclude soft-deleted items.
18 -- No schema change needed — fix is in the query.
19