feat(collection): implement saved search results as collections

This commit is contained in:
yiling
2026-05-25 17:29:45 +08:00
parent 0e5a4972b6
commit 794e7b3367
24 changed files with 2462 additions and 63 deletions
@@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "collections" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"filter" JSONB NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"project_id" TEXT NOT NULL,
CONSTRAINT "collections_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "collections_project_id_created_at_idx" ON "collections"("project_id", "created_at" DESC);
-- AddForeignKey
ALTER TABLE "collections" ADD CONSTRAINT "collections_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+16
View File
@@ -306,6 +306,7 @@ model Project {
invites Invite[] @relation("ProjectToInvite")
notifications Notification[] @relation("ProjectToNotification")
shareLinks ShareLink[] @relation("ProjectToShareLink")
collections Collection[] @relation("ProjectToCollection")
@@map("projects")
@@index([createdAt])
@@ -746,3 +747,18 @@ model Provider {
@@unique([teamId, name])
@@map("providers")
}
model Collection {
id String @id @default(ulid())
name String
/// [CollectionFilter]
filter Json
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
projectId String @map("project_id")
project Project @relation("ProjectToCollection", fields: [projectId], references: [id], onDelete: Cascade)
@@index([projectId, createdAt(sort: Desc)])
@@map("collections")
}