db: planets (planets+moons via parent_id) and inventory_items tables

This commit is contained in:
2026-09-28 22:01:41 +00:00
parent b79b77131f
commit 172f167a15
2 changed files with 41 additions and 0 deletions
+23
View File
@@ -35,6 +35,29 @@ export const jumpRoutes = sqliteTable(
(t) => [primaryKey({ columns: [t.fromSystem, t.toSystem] })],
)
// Bodies of a solar system: planets (parent_id NULL) and moons (parent_id = their planet's
// id). Generated when the system is generated, so every system has 2–5 planets, some with
// 1–3 moons. Insertion order is display order — a moon always follows its parent row.
export const planets = sqliteTable('planets', {
id: integer('id').primaryKey({ autoIncrement: true }),
systemId: integer('system_id').notNull().references(() => solarSystems.id),
parentId: integer('parent_id'), // NULL for a planet, set for a moon
name: text('name').notNull(),
type: text('type').notNull(),
hazard: integer('hazard', { mode: 'boolean' }).notNull().default(false),
explored: integer('explored', { mode: 'boolean' }).notNull().default(false),
})
// Dumb-simple cargo hold on the save: what exploration has found so far. SHIP SYSTEMS (#8)
// will spend parts from here later; nothing consumes it yet.
export const inventoryItems = sqliteTable('inventory_items', {
id: integer('id').primaryKey({ autoIncrement: true }),
saveId: integer('save_id').notNull().references(() => saves.id),
kind: text('kind').notNull(), // 'resource' | 'part'
name: text('name').notNull(),
qty: integer('qty').notNull().default(1),
})
// Append-only game log. Writers so far: new-game + jump events; later issues add more
// writers and a read endpoint.
export const events = sqliteTable('events', {