From 81f02209ea82b2bf8d2601048d2a32ef4670633e Mon Sep 17 00:00:00 2001 From: perfectra1n Date: Sun, 22 Mar 2026 09:22:55 -0700 Subject: [PATCH] feat(db): update index and fix suggestion from gemini --- apps/server/src/assets/db/schema.sql | 2 +- apps/server/src/migrations/migrations.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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