feat(game): tasks table + schema v7 backfill, admin registry (#44)
This commit is contained in:
+6
-1
@@ -97,7 +97,7 @@ async function seedStartingCrew(db: GameDb, saveId: number, seed: string): Promi
|
||||
// What each schema version added to a save. Saves created by older code lack the data newer
|
||||
// versions seed at new-game time, so ensureSave runs these steps in order for anything below
|
||||
// current — each step is idempotent (a no-op when its data already exists).
|
||||
export const SCHEMA_VERSION = 6 // v1: save + start region only · v2: bodies for every system · v3: starting crew · v4: starting ship · v5: tech tree · v6: mission board
|
||||
export const SCHEMA_VERSION = 7 // v1: save + start region only · v2: bodies for every system · v3: starting crew · v4: starting ship · v5: tech tree · v6: mission board · v7: tasks table
|
||||
|
||||
// Seeds the starting ship: one row per known type — core types built at base values, the rest
|
||||
// unbuilt (level/capacity 0) until a BUILD action.
|
||||
@@ -173,6 +173,11 @@ async function backfillSave(db: GameDb, save: { id: number; seed: string; schema
|
||||
await topUpMissionBoard(db) // idempotent — only inserts when fewer than MIN_AVAILABLE AVAILABLE contracts exist
|
||||
version = 6
|
||||
}
|
||||
if (version < 7) {
|
||||
// The tasks table itself is created by the DDL at open (CREATE TABLE IF NOT EXISTS) for
|
||||
// every file — new or old — so an upgraded save simply starts with an empty queue; stamp.
|
||||
version = 7
|
||||
}
|
||||
|
||||
if (from !== SCHEMA_VERSION) {
|
||||
await db.db.update(schema.saves).set({ schemaVersion: version }).where(eq(schema.saves.id, save.id))
|
||||
|
||||
Reference in New Issue
Block a user