From 577ce2bf6d5d8ddab88a28a29ed9acc2e417fe0c Mon Sep 17 00:00:00 2001
From: fly_mc <me@flymc.cc>
Date: Sun, 29 Sep 2024 01:40:49 +0800
Subject: [PATCH] add cw index

---
 ...{1727542814489-Pgroonga.js => 1727542814499-Pgroonga.js} | 6 ++++--
 packages/backend/src/models/Note.ts                         | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
 rename packages/backend/migration/{1727542814489-Pgroonga.js => 1727542814499-Pgroonga.js} (71%)

diff --git a/packages/backend/migration/1727542814489-Pgroonga.js b/packages/backend/migration/1727542814499-Pgroonga.js
similarity index 71%
rename from packages/backend/migration/1727542814489-Pgroonga.js
rename to packages/backend/migration/1727542814499-Pgroonga.js
index b8e3e4a468..923a835be3 100644
--- a/packages/backend/migration/1727542814489-Pgroonga.js
+++ b/packages/backend/migration/1727542814499-Pgroonga.js
@@ -1,8 +1,9 @@
-export class Pgroonga1727542814489 {
-    name = 'Pgroonga1727542814489'
+export class Pgroonga1727542814499 {
+    name = 'Pgroonga1727542814499'
 
     async up(queryRunner) {
 			await queryRunner.query(`CREATE INDEX "IDX_f27f5d88941e57442be75ba9c8" ON "note" USING "pgroonga" ("text")`);
+			await queryRunner.query(`CREATE INDEX "IDX_7cc8d9b0ee7861b4e5dc86ad85" ON "note" USING "pgroonga" ("cw" pgroonga_varchar_full_text_search_ops_v2)`);
 			await queryRunner.query(`CREATE INDEX "IDX_065d4d8f3b5adb4a08841eae3c" ON "user" USING "pgroonga" ("name" pgroonga_varchar_full_text_search_ops_v2)`);
 			await queryRunner.query(`CREATE INDEX "IDX_fcb770976ff8240af5799e3ffc" ON "user_profile" USING "pgroonga" ("description" pgroonga_varchar_full_text_search_ops_v2) `);
 
@@ -10,6 +11,7 @@ export class Pgroonga1727542814489 {
 
     async down(queryRunner) {
 			await queryRunner.query(`DROP INDEX "public"."IDX_f27f5d88941e57442be75ba9c8"`);
+			await queryRunner.query(`DROP INDEX "public"."IDX_7cc8d9b0ee7861b4e5dc86ad85"`);
 			await queryRunner.query(`DROP INDEX "public"."IDX_065d4d8f3b5adb4a08841eae3c"`);
 			await queryRunner.query(`DROP INDEX "public"."IDX_fcb770976ff8240af5799e3ffc"`);
 		}
diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts
index 87aa7ebb5b..88dfc2960c 100644
--- a/packages/backend/src/models/Note.ts
+++ b/packages/backend/src/models/Note.ts
@@ -75,6 +75,7 @@ export class MiNote {
 	})
 	public name: string | null;
 
+	@Index() // USING pgroonga pgroonga_varchar_full_text_search_ops_v2
 	@Column('varchar', {
 		length: 512, nullable: true,
 	})