Files
wownerogue/src/migrations/023_payment_safety.sql
T
jwinterm fad2a695bd Wownerogue
A browser-based roguelike synchronized with crypto block timing. A run is a race
against the next block: reach the exit before the block lands, or the house wins.
The same codebase runs the solo dungeon, the social Tavern, and operator-selected
PvP and race rulesets, with separate free and paid leaderboards.

Self-hostable under the MIT License. See README.md to run it, docs/ARCHITECTURE.md
for the design, and docs/DEPLOY.md to operate an instance.
2026-07-27 08:23:01 -04:00

13 lines
664 B
SQL

-- Migration 023: Payment safety: one game per confirmed single_game payment
--
-- M3: claiming a confirmed single_game payment must be atomic. The application locks the
-- payment row FOR UPDATE while linking the game, but this partial unique index is the
-- final backstop: at most one games row may reference a given payment_id. A concurrent
-- start that races past the lock hits a 23505 unique_violation (handled gracefully in
-- gameModeManager._processGameStartWithPayment as "already consumed"), so a single paid
-- entry can never spawn two games.
CREATE UNIQUE INDEX IF NOT EXISTS idx_games_payment_id
ON games(payment_id)
WHERE payment_id IS NOT NULL;