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
+11
View File
@@ -0,0 +1,11 @@
CREATE TABLE "saved_filters" (
"id" text PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"name" text NOT NULL,
"filters" jsonb NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "saved_filters_user_name" UNIQUE("user_id","name")
);
--> statement-breakpoint
ALTER TABLE "saved_filters" ADD CONSTRAINT "saved_filters_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+14
View File
@@ -141,6 +141,20 @@
"when": 1777547264277, "when": 1777547264277,
"tag": "0019_tiresome_genesis", "tag": "0019_tiresome_genesis",
"breakpoints": true "breakpoints": true
},
{
"idx": 20,
"version": "7",
"when": 1777547665970,
"tag": "0020_flaky_lilith",
"breakpoints": true
},
{
"idx": 21,
"version": "7",
"when": 1777547793864,
"tag": "0021_demonic_texas_twister",
"breakpoints": true
} }
] ]
} }
+1
View File
@@ -9,3 +9,4 @@ export * from "./gameComments"
export * from "./savedGames" export * from "./savedGames"
export * from "./reports" export * from "./reports"
export * from "./community-suggestions" 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),
],
)