Rescale a live economy in one migration
Moving the unit rate means moving every stored figure with it, in one operation, guarded so a resumed run cannot do it twice.
13 entries
Moving the unit rate means moving every stored figure with it, in one operation, guarded so a resumed run cannot do it twice.
Compute cost per claim from payouts that actually happened. Two accounting bugs make the modelled figure wrong, and both are easy to ship without noticing.
Dedupe on the transaction id, answer 200 to everything, and treat a reversal as the full chain — user credit and referral commission both.
Generate the day's tasks once, track progress against a date key, and pay the completion bonus exactly once — no midnight cron required.
A table of conditions, a checker that runs after activity, and a unique key so an achievement can only be awarded once.
Percentage of earnings, one-off signup bonus, or a share of what you earn from the referral. The arithmetic that decides which one bankrupts you.
Every manual adjustment writes a ledger row and an audit row, inside one transaction. An admin panel that edits a balance directly is how books stop balancing.
Compute the fee once, show the net before they confirm, and keep every threshold in the settings table so repricing is not a code change.
Make the column unsigned, check inside the transaction, and let a clawback take a balance to zero rather than below it.
A caller-supplied key with a unique index turns every retry, refresh and double-click into a no-op. The single most valuable column in a payments schema.
A unique index on your own reference turns duplicate callbacks, browser refreshes and manual replays into no-ops instead of free balance.
Debit on request, not on approval. The state machine that makes double payouts and phantom balances impossible.
Lock both rows in a fixed order, check inside the transaction, and write a ledger entry for each side. Skipping any of the three is how balances drift.