Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fixed primary keys, added indexes
azivner11bfae4007c1
diff --git a/migrations/0008__fix_note_history.sql b/migrations/0008__fix_note_history.sqlnew file mode 100644index 0000000000..fa71edf37e--- /dev/null+++ b/migrations/0008__fix_note_history.sql@@ -0,0 +1,15 @@+CREATE TABLE `notes_history_mig` (+ `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,+ `note_id` INT,+ `note_title` TEXT,+ `note_text` TEXT,+ `date_modified_from` INT,+ `date_modified_to` INT,+ `encryption` INTEGER DEFAULT 0+);++INSERT INTO notes_history (id, note_id, note_title, note_text, date_modified_from, date_modified_to, encryption)+ SELECT id, note_id, note_title, note_text, date_modified_from, date_modified_to, encryption FROM notes_history;++DROP TABLE notes_history;+ALTER TABLE notes_history_mig RENAME TO notes_history;\ No newline at end of filediff --git a/migrations/0009__indexes.sql b/migrations/0009__indexes.sqlnew file mode 100644index 0000000000..b427a9337e--- /dev/null+++ b/migrations/0009__indexes.sql@@ -0,0 +1,41 @@+CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (+ `note_id`+);++CREATE INDEX `IDX_images_note_id` ON `images` (+ `note_id`+);++CREATE INDEX `IDX_links_note_id` ON `links` (+ `note_id`+);++CREATE INDEX `IDX_audit_log_note_id` ON `audit_log` (+ `note_id`+);++CREATE INDEX `IDX_audit_log_date_modified` ON `audit_log` (+ `date_modified`+);++CREATE TABLE `notes_mig` (+ `note_id` TEXT NOT NULL,+ `note_title` TEXT,+ `note_text` TEXT,+ `note_clone_id` TEXT,+ `date_created` INT,+ `date_modified` INT,+ `encryption` INT,+ `is_deleted` INTEGER NOT NULL DEFAULT 0,+ PRIMARY KEY(`note_id`)+);++INSERT INTO notes_mig (note_id, note_title, note_text, note_clone_id, date_created, date_modified, encryption)+ SELECT note_id, note_title, note_text, note_clone_id, date_created, date_modified, encryption FROM notes;++DROP TABLE notes;+ALTER TABLE notes_mig RENAME TO notes;++CREATE INDEX `IDX_notes_is_deleted` ON `notes` (+ `is_deleted`+);\ No newline at end of filediff --git a/public/javascripts/note_history.js b/public/javascripts/note_history.jsindex 62a56c2e36..d0c57213cd 100644--- a/public/javascripts/note_history.js+++ b/public/javascripts/note_history.js@@ -45,6 +45,7 @@ $(document).bind('keydown', 'alt+h', showCurrentNoteHistory);$("#note-history-list").on('change', () => {const optVal = $("#note-history-list").find(":selected").val();+const historyItem = globalHistoryItems.find(r => r.id == optVal); // non-strict comparison is important here!!!$("#note-history-title").html(historyItem.note_title);diff --git a/services/migration.js b/services/migration.jsindex c874c15d38..d129c866b7 100644--- a/services/migration.js+++ b/services/migration.js@@ -2,7 +2,7 @@ const backup = require('./backup');const sql = require('./sql');const fs = require('fs-extra');-const APP_DB_VERSION = 7;+const APP_DB_VERSION = 9;const MIGRATIONS_DIR = "./migrations";async function migrate() {