mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-27 19:34:38 +00:00
feat(collection): implement saved search results as collections
This commit is contained in:
@@ -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;
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user