feat(schema): add source enum, nullable steamAppId, onlineMultiplayerStatus to games table
This commit is contained in:
+27
-3
@@ -1,16 +1,33 @@
|
|||||||
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", [
|
||||||
|
"steam",
|
||||||
|
"manual",
|
||||||
|
"gog",
|
||||||
|
"epic",
|
||||||
|
])
|
||||||
|
|
||||||
|
export const onlineMultiplayerStatusEnum = pgEnum(
|
||||||
|
"online_multiplayer_status",
|
||||||
|
["none", "supported", "unknown"],
|
||||||
|
)
|
||||||
|
|
||||||
|
export const games = pgTable(
|
||||||
|
"games",
|
||||||
|
{
|
||||||
id: text("id")
|
id: text("id")
|
||||||
.primaryKey()
|
.primaryKey()
|
||||||
.$defaultFn(() => crypto.randomUUID()),
|
.$defaultFn(() => crypto.randomUUID()),
|
||||||
steamAppId: integer("steam_app_id").unique().notNull(),
|
steamAppId: integer("steam_app_id").unique(),
|
||||||
|
source: gameSourceEnum("source").default("steam").notNull(),
|
||||||
title: text("title").notNull(),
|
title: text("title").notNull(),
|
||||||
description: text("description"),
|
description: text("description"),
|
||||||
publisher: text("publisher"),
|
publisher: text("publisher"),
|
||||||
@@ -19,8 +36,15 @@ export const games = pgTable("games", {
|
|||||||
headerImage: text("header_image"),
|
headerImage: text("header_image"),
|
||||||
capsuleImage: text("capsule_image"),
|
capsuleImage: text("capsule_image"),
|
||||||
storeUrl: text("store_url"),
|
storeUrl: text("store_url"),
|
||||||
|
onlineMultiplayerStatus: onlineMultiplayerStatusEnum(
|
||||||
|
"online_multiplayer_status",
|
||||||
|
)
|
||||||
|
.default("unknown")
|
||||||
|
.notNull(),
|
||||||
lastSync: timestamp("last_sync"),
|
lastSync: timestamp("last_sync"),
|
||||||
syncStatus: text("sync_status").default("pending"),
|
syncStatus: text("sync_status").default("pending"),
|
||||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||||
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
||||||
})
|
},
|
||||||
|
(table) => [index("games_source_idx").on(table.source)],
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user