From d96053dbbebe315891b3d4fc477db4bccdb9a672 Mon Sep 17 00:00:00 2001 From: hpkoh Date: Wed, 26 Oct 2022 15:33:44 +0800 Subject: [PATCH] WIP: [questions][fix] workaround for prisma bug --- .../migration.sql | 8 -------- .../20221025172425_add_full_text_search/migration.sql | 5 +++++ apps/portal/prisma/schema.prisma | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql create mode 100644 apps/portal/prisma/migrations/20221025172425_add_full_text_search/migration.sql diff --git a/apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql b/apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql deleted file mode 100644 index 2aed7085..00000000 --- a/apps/portal/prisma/migrations/20221014105030_add_question_content_search/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ --- AlterTable -ALTER TABLE "QuestionsQuestion" ADD COLUMN "contentSearch" TSVECTOR - GENERATED ALWAYS AS - to_tsvector('english', coalesce(content, '')) - STORED; - --- CreateIndex -CREATE INDEX "QuestionsQuestion_contentSearch_idx" ON "QuestionsQuestion" USING GIN("textSearch"); \ No newline at end of file diff --git a/apps/portal/prisma/migrations/20221025172425_add_full_text_search/migration.sql b/apps/portal/prisma/migrations/20221025172425_add_full_text_search/migration.sql new file mode 100644 index 00000000..a52b7ebf --- /dev/null +++ b/apps/portal/prisma/migrations/20221025172425_add_full_text_search/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "QuestionsQuestion" ADD COLUMN "contentSearch" tsvector; + +-- CreateIndex +CREATE INDEX "QuestionsQuestion_contentSearch_idx" ON "QuestionsQuestion" USING GIN ("contentSearch"); diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 42f1b974..fad7f441 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -415,9 +415,9 @@ model QuestionsQuestion { comments QuestionsQuestionComment[] answers QuestionsAnswer[] - contentSearch Unsupported("TSVECTOR")? + contentSearch Unsupported("tsvector")? @default(dbgenerated()) - @@index([contentSearch]) + @@index([contentSearch], type: Gin) @@index([lastSeenAt, id]) @@index([upvotes, id]) }