Skip to content

Build your personal knowledge base with Trilium Notes

feat(db): update index and fix suggestion from gemini

perfectra1n81f02209ea82
diff --git a/apps/server/src/assets/db/schema.sql b/apps/server/src/assets/db/schema.sql
index f7ee0a4a08..cb7c066d15 100644
--- a/apps/server/src/assets/db/schema.sql
+++ b/apps/server/src/assets/db/schema.sql
@@ -79,7 +79,7 @@ CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes"
`entityId`
);
CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` (`noteId`,`parentNoteId`);
-CREATE INDEX IDX_branches_parentNoteId ON branches (parentNoteId);
+CREATE INDEX IDX_branches_parentNoteId_isDeleted_notePosition ON branches (parentNoteId, isDeleted, notePosition);
CREATE INDEX `IDX_notes_title` ON `notes` (`title`);
CREATE INDEX `IDX_notes_type` ON `notes` (`type`);
CREATE INDEX `IDX_notes_dateCreated` ON `notes` (`dateCreated`);
diff --git a/apps/server/src/migrations/migrations.ts b/apps/server/src/migrations/migrations.ts
index 778fb88beb..ae88e9a3a6 100644
--- a/apps/server/src/migrations/migrations.ts
+++ b/apps/server/src/migrations/migrations.ts
@@ -22,8 +22,9 @@ const MIGRATIONS: (SqlMigration | JsMigration)[] = [
ON attributes (isDeleted, utcDateModified);
CREATE INDEX IF NOT EXISTS IDX_attachments_isDeleted_utcDateModified
ON attachments (isDeleted, utcDateModified);
- CREATE INDEX IF NOT EXISTS IDX_attachments_utcDateScheduledForErasureSince
- ON attachments (utcDateScheduledForErasureSince);
+ DROP INDEX IF EXISTS IDX_branches_parentNoteId;
+ CREATE INDEX IF NOT EXISTS IDX_branches_parentNoteId_isDeleted_notePosition
+ ON branches (parentNoteId, isDeleted, notePosition);
`
},
// Migrate aiChat notes to code notes since LLM integration has been removed