feat: add savedGames schema

This commit is contained in:
2026-04-26 09:59:47 -05:00
parent fb686b6786
commit 9964c99c4a
2 changed files with 28 additions and 0 deletions
+1
View File
@@ -7,3 +7,4 @@ export * from "./performanceEntries"
export * from "./gamePlatformSupport"
export * from "./communityPresets"
export * from "./gameComments"
export * from "./savedGames"
+27
View File
@@ -0,0 +1,27 @@
import {
pgTable,
text,
timestamp,
unique,
} from "drizzle-orm/pg-core"
import { user } from "./auth"
import { games } from "./games"
export const savedGames = pgTable(
"saved_games",
{
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
userId: text("user_id")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
gameId: text("game_id")
.notNull()
.references(() => games.id, { onDelete: "cascade" }),
createdAt: timestamp("created_at").defaultNow().notNull(),
},
(table) => [
unique("saved_games_user_game_unique").on(table.userId, table.gameId),
],
)