summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/Note.ts
diff options
context:
space:
mode:
authoranatawa12 <anatawa12@icloud.com>2025-05-03 12:57:50 +0900
committerGitHub <noreply@github.com>2025-05-03 12:57:50 +0900
commit1af98b690ba7cccb14c524df83c5bb297896a38f (patch)
tree1dbbccbe6a7654c5309bd3e240f60ad5f5d064d8 /packages/backend/src/models/Note.ts
parentfix(frontend): tweak universal ui rendering (diff)
downloadmisskey-1af98b690ba7cccb14c524df83c5bb297896a38f.tar.gz
misskey-1af98b690ba7cccb14c524df83c5bb297896a38f.tar.bz2
misskey-1af98b690ba7cccb14c524df83c5bb297896a38f.zip
feat: CREATE INDEX CONCURRENTLY for "userId" "id" composite note index if admin wish. (#15915)
* chore: CREATE INDEX CONCURRENTLY for "userId" "id" composite note index * chore: remove { concurrent: true } and comment why * update comment * feat: add MISSKEY_MIGRATION_CREATE_INDEX_CONCURRENTLY option * fix: spdx license header * alter comment * chore: improve behavior when migration failure * docs(changelog): 2025.4.1 で追加されたインデックスの再生成をノートの追加しながら行えるようになりました * ちょっと表現を変更 --------- Co-authored-by: 饺子w (Yumechi) <35571479+eternal-flame-ad@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/models/Note.ts')
-rw-r--r--packages/backend/src/models/Note.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts
index abaf615bcf..3dcbdb735b 100644
--- a/packages/backend/src/models/Note.ts
+++ b/packages/backend/src/models/Note.ts
@@ -10,6 +10,16 @@ import { MiUser } from './User.js';
import { MiChannel } from './Channel.js';
import type { MiDriveFile } from './DriveFile.js';
+// Note: When you create a new index for existing column of this table,
+// it might be better to index concurrently under isConcurrentIndexMigrationEnabled flag
+// by editing generated migration file since this table is very large,
+// and it will make a long lock to create index in most cases.
+// Please note that `CREATE INDEX CONCURRENTLY` is not supported in transaction,
+// so you need to set `transaction = false` in migration if isConcurrentIndexMigrationEnabled() is true.
+// Please refer 1745378064470-composite-note-index.js for example.
+// You should not use `@Index({ concurrent: true })` decorator because database initialization for test will fail
+// because it will always run CREATE INDEX in transaction based on decorators.
+// Not appending `{ concurrent: true }` to `@Index` will not cause any problem in production,
@Index(['userId', 'id'])
@Entity('note')
export class MiNote {