From 3da593e619da0ccc2fabf5c6d6e6ffdb33eb5b04 Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sat, 25 Apr 2026 18:18:48 +0800 Subject: [PATCH] feat(schema): add source enum, nullable steamAppId, onlineMultiplayerStatus to games table --- lib/db/schema/games.ts | 60 +++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/lib/db/schema/games.ts b/lib/db/schema/games.ts index 56b7a2d..8ca6ca9 100644 --- a/lib/db/schema/games.ts +++ b/lib/db/schema/games.ts @@ -1,26 +1,50 @@ import { integer, jsonb, + pgEnum, pgTable, text, timestamp, + index, } from "drizzle-orm/pg-core" -export const games = pgTable("games", { - id: text("id") - .primaryKey() - .$defaultFn(() => crypto.randomUUID()), - steamAppId: integer("steam_app_id").unique().notNull(), - title: text("title").notNull(), - description: text("description"), - publisher: text("publisher"), - developer: text("developer"), - genres: jsonb("genres").$type(), - headerImage: text("header_image"), - capsuleImage: text("capsule_image"), - storeUrl: text("store_url"), - lastSync: timestamp("last_sync"), - syncStatus: text("sync_status").default("pending"), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at").defaultNow().notNull(), -}) +export const gameSourceEnum = pgEnum("game_source", [ + "steam", + "manual", + "gog", + "epic", +]) + +export const onlineMultiplayerStatusEnum = pgEnum( + "online_multiplayer_status", + ["none", "supported", "unknown"], +) + +export const games = pgTable( + "games", + { + id: text("id") + .primaryKey() + .$defaultFn(() => crypto.randomUUID()), + steamAppId: integer("steam_app_id").unique(), + source: gameSourceEnum("source").default("steam").notNull(), + title: text("title").notNull(), + description: text("description"), + publisher: text("publisher"), + developer: text("developer"), + genres: jsonb("genres").$type(), + headerImage: text("header_image"), + capsuleImage: text("capsule_image"), + storeUrl: text("store_url"), + onlineMultiplayerStatus: onlineMultiplayerStatusEnum( + "online_multiplayer_status", + ) + .default("unknown") + .notNull(), + lastSync: timestamp("last_sync"), + syncStatus: text("sync_status").default("pending"), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at").defaultNow().notNull(), + }, + (table) => [index("games_source_idx").on(table.source)], +)