VNOX-Server/hub/migrations/0004_email_resend_chain.sql
loki5512344 fea876654b
fix(hub): bind email budget reserve to a bounded resend chain
The global reserve is claimed atomically with the budget check by deleting a live
attempt for the same address (under 5 failures, under 3 resends, chain under 30
minutes), so it cannot fund mail to other addresses, branch or race.
2026-10-24 17:48:20 +02:00

5 lines
350 B
SQL

-- Resends from a browser with a live attempt may draw on a reserved global budget, but
-- only along a bounded chain: each attempt records how many resends led to it and when
-- the chain began.
ALTER TABLE email_attempts ADD COLUMN resends INTEGER NOT NULL DEFAULT 0;
ALTER TABLE email_attempts ADD COLUMN chain_started INTEGER NOT NULL DEFAULT 0;