db: CHECK constraints on money columns #123

Stängd
öppnade 2026-10-08 21:12:30 +00:00 av supernaut · 0 kommentarer
Ägare

What

Money invariants are held only in code.

Why

A future bug that writes a bad row would pass silently.

Fix

Migration adding CHECKs: amount_gross = amount_net + amount_vat, amount_gross > 0 and vat_rate_bps >= 0 on charge and invoice, and amount_minor > 0 on refund.

Done when

  • Migration applies on existing rows.
  • Schema test shows a mismatched row is rejected.
## What Money invariants are held only in code. ## Why A future bug that writes a bad row would pass silently. ## Fix Migration adding CHECKs: `amount_gross = amount_net + amount_vat`, `amount_gross > 0` and `vat_rate_bps >= 0` on `charge` and `invoice`, and `amount_minor > 0` on `refund`. ## Done when - [ ] Migration applies on existing rows. - [ ] Schema test shows a mismatched row is rejected.
supernaut lade till detta till projektet Bitborg Payment 2026-10-08 21:14:16 +00:00
Logga in för att delta i denna konversation.
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-payment#123
Ingen beskrivning angiven.