feat: create saved filters table
This commit is contained in:
@@ -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
@@ -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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -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