feat(schema): add source enum, nullable steamAppId, onlineMultiplayerStatus to games table

This commit is contained in:
2026-04-25 18:18:48 +08:00
parent 5bc5f29281
commit 3da593e619
+42 -18
View File
@@ -1,26 +1,50 @@
import { import {
integer, integer,
jsonb, jsonb,
pgEnum,
pgTable, pgTable,
text, text,
timestamp, timestamp,
index,
} from "drizzle-orm/pg-core" } from "drizzle-orm/pg-core"
export const games = pgTable("games", { export const gameSourceEnum = pgEnum("game_source", [
id: text("id") "steam",
.primaryKey() "manual",
.$defaultFn(() => crypto.randomUUID()), "gog",
steamAppId: integer("steam_app_id").unique().notNull(), "epic",
title: text("title").notNull(), ])
description: text("description"),
publisher: text("publisher"), export const onlineMultiplayerStatusEnum = pgEnum(
developer: text("developer"), "online_multiplayer_status",
genres: jsonb("genres").$type<string[]>(), ["none", "supported", "unknown"],
headerImage: text("header_image"), )
capsuleImage: text("capsule_image"),
storeUrl: text("store_url"), export const games = pgTable(
lastSync: timestamp("last_sync"), "games",
syncStatus: text("sync_status").default("pending"), {
createdAt: timestamp("created_at").defaultNow().notNull(), id: text("id")
updatedAt: timestamp("updated_at").defaultNow().notNull(), .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<string[]>(),
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)],
)