feat: create saved filters table

This commit is contained in:
2026-04-30 19:16:45 +08:00
parent 4c0284ef9e
commit 4cfd046953
6 changed files with 4138 additions and 0 deletions
+1
View File
@@ -9,3 +9,4 @@ export * from "./gameComments"
export * from "./savedGames"
export * from "./reports"
export * from "./community-suggestions"
export * from "./saved-filters"
+30
View File
@@ -0,0 +1,30 @@
import {
pgTable,
text,
timestamp,
jsonb,
unique,
} from "drizzle-orm/pg-core"
import { user } from "./auth"
export const savedFilters = pgTable(
"saved_filters",
{
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
userId: text("user_id")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
name: text("name").notNull(),
filters: jsonb("filters").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at")
.defaultNow()
.$onUpdate(() => new Date())
.notNull(),
},
(table) => [
unique("saved_filters_user_name").on(table.userId, table.name),
],
)