feat: create saved filters table
This commit is contained in:
@@ -9,3 +9,4 @@ export * from "./gameComments"
|
||||
export * from "./savedGames"
|
||||
export * from "./reports"
|
||||
export * from "./community-suggestions"
|
||||
export * from "./saved-filters"
|
||||
|
||||
@@ -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),
|
||||
],
|
||||
)
|
||||
Reference in New Issue
Block a user