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
removed foreign key from notes_tree parent_note_id because of sync issues
azivner9ca7223aea1e
diff --git a/migrations/0058__remove_foreign_key_from_notes_tree.sql b/migrations/0058__remove_foreign_key_from_notes_tree.sqlnew file mode 100644index 0000000000..aac3d68b84--- /dev/null+++ b/migrations/0058__remove_foreign_key_from_notes_tree.sql@@ -0,0 +1,29 @@+CREATE TABLE IF NOT EXISTS "notes_tree_mig" (+ `note_tree_id` TEXT NOT NULL,+ `note_id` TEXT NOT NULL,+ `parent_note_id` TEXT NOT NULL,+ `note_position` INTEGER NOT NULL,+ `prefix` TEXT,+ `is_expanded` BOOLEAN,+ `is_deleted` INTEGER NOT NULL DEFAULT 0,+ `date_modified` TEXT NOT NULL,+ FOREIGN KEY(note_id) REFERENCES notes(note_id),+ PRIMARY KEY(`note_tree_id`)+);++INSERT INTO notes_tree_mig (note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified)+ SELECT note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified FROM notes_tree;++DROP TABLE notes_tree;+ALTER TABLE notes_tree_mig RENAME TO notes_tree;++CREATE INDEX `IDX_notes_tree_note_tree_id` ON `notes_tree` (+ `note_tree_id`+);+CREATE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (+ `note_id`,+ `parent_note_id`+);+CREATE INDEX `IDX_notes_tree_note_id` ON `notes_tree` (+ `note_id`+);\ No newline at end of filediff --git a/services/app_info.js b/services/app_info.jsindex bd51115a9a..2bc32d8577 100644--- a/services/app_info.js+++ b/services/app_info.js@@ -3,7 +3,7 @@const build = require('./build');const packageJson = require('../package');-const APP_DB_VERSION = 57;+const APP_DB_VERSION = 58;module.exports = {app_version: packageJson.version,diff --git a/services/build.js b/services/build.jsindex 46382d5f5a..e8511792e8 100644--- a/services/build.js+++ b/services/build.js@@ -1 +1 @@-module.exports = { build_date:"2017-12-18T23:45:10-05:00", build_revision: "b0e2d99a7b1073e9ee593b386afa19a62a2651eb" };+module.exports = { build_date:"2017-12-20T19:52:26-05:00", build_revision: "00e316fe290a491ac00f15bc5de495e66e64bf2d" };diff --git a/services/migration.js b/services/migration.jsindex 8748a1cfac..3bd9192c48 100644--- a/services/migration.js+++ b/services/migration.js@@ -49,6 +49,9 @@ async function migrate() {try {log.info("Attempting migration to version " + mig.dbVersion);+ // needs to happen outside of the transaction (otherwise it's a NO-OP)+ await sql.execute("PRAGMA foreign_keys = OFF");+await sql.doInTransaction(async () => {if (mig.type === 'sql') {const migrationSql = fs.readFileSync(MIGRATIONS_DIR + "/" + mig.file).toString('utf8');@@ -68,6 +71,7 @@ async function migrate() {}await options.setOption("db_version", mig.dbVersion);+});log.info("Migration to version " + mig.dbVersion + " has been successful.");@@ -82,6 +86,10 @@ async function migrate() {break;}+ finally {+ // make sure foreign keys are enabled even if migration script disables them+ await sql.execute("PRAGMA foreign_keys = ON");+ }}if (sql.isDbUpToDate()) {