feat: add savedGames schema
This commit is contained in:
@@ -7,3 +7,4 @@ export * from "./performanceEntries"
|
|||||||
export * from "./gamePlatformSupport"
|
export * from "./gamePlatformSupport"
|
||||||
export * from "./communityPresets"
|
export * from "./communityPresets"
|
||||||
export * from "./gameComments"
|
export * from "./gameComments"
|
||||||
|
export * from "./savedGames"
|
||||||
|
|||||||
@@ -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),
|
||||||
|
],
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user