Skip to content

Build your personal knowledge base with Trilium Notes

note_id - parent_note_id index needs to be unique

azivner53ee1fa5ed6b
diff --git a/db/schema.sql b/db/schema.sql
index 8a5de85ccb..4d6b029dc2 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -70,7 +70,7 @@ CREATE INDEX `IDX_notes_is_deleted` ON `notes` (
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` (
+CREATE UNIQUE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (
`note_id`,
`parent_note_id`
);
diff --git a/migrations/0061__change_index_to_unique.sql b/migrations/0061__change_index_to_unique.sql
new file mode 100644
index 0000000000..005658567f
--- /dev/null
+++ b/migrations/0061__change_index_to_unique.sql
@@ -0,0 +1,6 @@
+DROP INDEX IDX_notes_tree_note_id_parent_note_id;
+
+CREATE UNIQUE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (
+ `note_id`,
+ `parent_note_id`
+);
\ No newline at end of file
diff --git a/services/app_info.js b/services/app_info.js
index 208834ffa1..3fbb1ac146 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 = 60;
+const APP_DB_VERSION = 61;
module.exports = {
app_version: packageJson.version,