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:
@@ -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)
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user