fix(db): add 'math-sprint' to database schema enums

Update all database schemas to include 'math-sprint':
- arcade-rooms.ts: Add to gameName enum
- arcade-sessions.ts: Add to currentGame enum
- room-game-configs.ts: Add to gameName enum and documentation

CRITICAL ISSUE DEMONSTRATED:
This is the schema coupling problem (Issue #1 from AUDIT_2).
Must manually update database schemas for every new game.
Breaks modularity - cannot "just register and go".

Without this change, TypeScript compilation fails with:
  Type '"math-sprint"' is not assignable to type '...'

Recommendation from audit: Change schemas to accept any string,
validate against registry at runtime instead of compile-time enums.
This commit is contained in:
Thomas Hallock
2025-10-15 21:11:13 -05:00
parent 0c05a7c6bb
commit 7b112a98ba
3 changed files with 5 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ export const arcadeRooms = sqliteTable('arcade_rooms', {
// Game configuration (nullable to support game selection in room)
gameName: text('game_name', {
enum: ['matching', 'memory-quiz', 'complement-race', 'number-guesser'],
enum: ['matching', 'memory-quiz', 'complement-race', 'number-guesser', 'math-sprint'],
}),
gameConfig: text('game_config', { mode: 'json' }), // Game-specific settings (nullable when no game selected)

View File

@@ -17,7 +17,7 @@ export const arcadeSessions = sqliteTable('arcade_sessions', {
// Session metadata
currentGame: text('current_game', {
enum: ['matching', 'memory-quiz', 'complement-race', 'number-guesser'],
enum: ['matching', 'memory-quiz', 'complement-race', 'number-guesser', 'math-sprint'],
}).notNull(),
gameUrl: text('game_url').notNull(), // e.g., '/arcade/matching'

View File

@@ -20,7 +20,7 @@ export const roomGameConfigs = sqliteTable(
// Game identifier
gameName: text('game_name', {
enum: ['matching', 'memory-quiz', 'complement-race', 'number-guesser'],
enum: ['matching', 'memory-quiz', 'complement-race', 'number-guesser', 'math-sprint'],
}).notNull(),
// Game-specific configuration JSON
@@ -28,6 +28,8 @@ export const roomGameConfigs = sqliteTable(
// - matching: { gameType, difficulty, turnTimer }
// - memory-quiz: { selectedCount, displayTime, selectedDifficulty, playMode }
// - complement-race: TBD
// - number-guesser: { minNumber, maxNumber, roundsToWin }
// - math-sprint: { difficulty, questionsPerRound, timePerQuestion }
config: text('config', { mode: 'json' }).notNull(),
// Timestamps