From 9964c99c4a9e121b74aa6ca98618a85b693052b0 Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sun, 26 Apr 2026 09:59:47 -0500 Subject: [PATCH] feat: add savedGames schema --- lib/db/schema/index.ts | 1 + lib/db/schema/savedGames.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 lib/db/schema/savedGames.ts diff --git a/lib/db/schema/index.ts b/lib/db/schema/index.ts index cd6d644..f46495d 100644 --- a/lib/db/schema/index.ts +++ b/lib/db/schema/index.ts @@ -7,3 +7,4 @@ export * from "./performanceEntries" export * from "./gamePlatformSupport" export * from "./communityPresets" export * from "./gameComments" +export * from "./savedGames" diff --git a/lib/db/schema/savedGames.ts b/lib/db/schema/savedGames.ts new file mode 100644 index 0000000..0934298 --- /dev/null +++ b/lib/db/schema/savedGames.ts @@ -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), + ], +)