Skip to content

Build your personal knowledge base with Trilium Notes

small changes to table names (notes_image => note_images etc.)

azivner11e173aeaccb
diff --git a/db/main_notes_image.sql b/db/main_notes_image.sql
index 4c0a70ba0c..20c630916e 100644
--- a/db/main_notes_image.sql
+++ b/db/main_notes_image.sql
@@ -1 +1 @@
-INSERT INTO notes_image (noteImageId, noteId, imageId, isDeleted, dateModified, dateCreated) VALUES ('2EtgRRPfk4Fi', '1Heh2acXfPNt', 'ed64aET6i379', 0, '2018-01-08T04:41:30.663Z', '2018-01-08T04:41:30.663Z');
\ No newline at end of file
+INSERT INTO note_images (noteImageId, noteId, imageId, isDeleted, dateModified, dateCreated) VALUES ('2EtgRRPfk4Fi', '1Heh2acXfPNt', 'ed64aET6i379', 0, '2018-01-08T04:41:30.663Z', '2018-01-08T04:41:30.663Z');
\ No newline at end of file
diff --git a/db/main_notes_tree.sql b/db/main_notes_tree.sql
index af69772403..e75f3e6845 100644
--- a/db/main_notes_tree.sql
+++ b/db/main_notes_tree.sql
@@ -1,52 +1,52 @@
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('dLgtLUFn3GoN', '1Heh2acXfPNt', 'root', 21, null, 1, 0, '2017-12-23T00:46:39.304Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('QLfS835GSfIh', '3RkyK9LI18dO', '1Heh2acXfPNt', 1, null, 1, 0, '2017-12-23T01:20:04.181Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('QJAcYJ1gGUh9', 'L1Ox40M1aEyy', '3RkyK9LI18dO', 0, null, 0, 0, '2017-12-23T01:20:45.365Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('wLTa2l3lYi83', 'HJusZTbBU494', '3RkyK9LI18dO', 2, null, 1, 0, '2017-12-23T01:20:50.709Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('yMhwsE7uvEij', '3oldoiMUPOlr', 'HJusZTbBU494', 1, null, 1, 0, '2017-12-23T01:20:55.775Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('EjQTcVVHFmmZ', 'MG0wntwILQW6', '3oldoiMUPOlr', 1, null, 1, 0, '2017-12-23T01:21:10.517Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('jvhKcwz4pYTr', 'ZC78NlmdXeC6', 'WdWZFuWNVDZk', 0, null, 1, 0, '2017-12-23T04:06:21.579Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('CarTrwkGVcPz', 'NncfGH8dyNjJ', 'WdWZFuWNVDZk', 1, null, 0, 0, '2017-12-23T04:06:24.012Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('6M7qPlr7at6N', 'eouCLkjbruai', 'NncfGH8dyNjJ', 0, null, 0, 0, '2017-12-23T01:23:28.291Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('tQgognnAH9WI', 'C44aq4mkaX67', 'NncfGH8dyNjJ', 1, null, 0, 0, '2017-12-23T01:23:31.879Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('xyAi7MmgvAgR', 'C44aq4mkaX67', 'ZC78NlmdXeC6', 1, null, 0, 0, '2017-12-23T01:23:47.756Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('xQ3fjRp9yaPq', 'I6Cw88AirBBl', 'C44aq4mkaX67', 0, null, 0, 0, '2017-12-23T01:24:04.681Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('2GOsNT5LsvTP', 'mcEwFMSjhlvL', 'C44aq4mkaX67', 1, null, 0, 0, '2017-12-23T01:29:35.974Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('RxUiraiR655R', 'CF2lUIJAr6Ey', 'NncfGH8dyNjJ', 2, null, 0, 0, '2017-12-23T01:34:37.658Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('mZuSrZ18Zmv0', 'xkXwueRoDNeN', 'MG0wntwILQW6', 0, null, 0, 0, '2017-12-23T01:35:40.306Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('hbcWTnEnXPwF', 'eXHZAKsMYgur', '1Heh2acXfPNt', 3, null, 1, 0, '2017-12-23T03:32:42.868Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('8a3aNxjG0nu7', '2WU27ekfy07E', 'eXHZAKsMYgur', 0, null, 0, 0, '2017-12-23T03:32:49.379Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('4Tu6vaPdCxCM', 'TjWEndYCCg7g', 'eXHZAKsMYgur', 1, null, 0, 0, '2017-12-23T03:33:23.584Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('lBPOmhP12egP', '8nRNDJGyGs2Z', 'TjWEndYCCg7g', 0, null, 0, 0, '2017-12-23T03:33:37.327Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('C5ipVqeDWySp', '9zSwD89vgzNO', '8nRNDJGyGs2Z', 0, null, 0, 0, '2017-12-23T03:37:04.912Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('uSitzbGcSATJ', 'u5t1EvWa3CMO', 'TjWEndYCCg7g', 1, null, 0, 0, '2017-12-23T03:39:21.918Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('GZ6aRI8rdSJt', '8nRNDJGyGs2Z', 'MG0wntwILQW6', 1, '', 0, 0, '2017-12-23T03:42:28.310Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('HsN4600rQoL9', 'Iha4YwchR413', '3oldoiMUPOlr', 0, null, 1, 0, '2017-12-23T03:44:30.945Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('uipfvAfwWRgx', '6ZuXjCSWgjB4', 'HJusZTbBU494', 0, null, 0, 0, '2017-12-23T03:44:54.096Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('nMRpPWWH8WRk', 'GpGnjmcAPeWG', '6ZuXjCSWgjB4', 0, null, 1, 0, '2017-12-23T03:44:57.036Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('c4wt27WNjepw', '21K84UqGhqlt', 'GpGnjmcAPeWG', 0, null, 0, 0, '2017-12-23T03:45:10.933Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('0fpnraUGs9Kl', 'rz5t0r9Qr2WC', 'HJusZTbBU494', 2, null, 1, 0, '2017-12-23T03:45:20.914Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('d8L8zYlLTbym', 'R6pheWjdwmNU', 'rz5t0r9Qr2WC', 0, null, 1, 0, '2017-12-23T03:45:28.002Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('T4USGzfllu5t', '5v5Dx6LMHXIO', 'Iha4YwchR413', 0, null, 0, 0, '2017-12-23T03:45:44.184Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('c4JgFNIobvQW', 'MLQjmREtcnJ3', 'R6pheWjdwmNU', 0, null, 0, 0, '2017-12-23T03:47:48.208Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('nfWjptAU2ZDg', 'pTTjrxgnvURB', 'R6pheWjdwmNU', 1, null, 0, 0, '2017-12-23T03:47:55.932Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('T2ToYBfyPy0g', 'cFK9sGYZaMWs', 'rz5t0r9Qr2WC', 1, null, 0, 0, '2017-12-23T03:49:32.210Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('NG4gbKOnsM3v', '21K84UqGhqlt', 'MLQjmREtcnJ3', 0, '28. 11. 2017', 0, 0, '2017-12-23T03:53:38.110Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('Fstg4tkccO4N', '5v5Dx6LMHXIO', 'MLQjmREtcnJ3', 1, '21. 12. 2017', 0, 0, '2017-12-23T03:53:49.737Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('MN8B7qXDUViO', 'xkXwueRoDNeN', 'MLQjmREtcnJ3', 2, '22. 12. 2017', 0, 0, '2017-12-23T03:53:57.486Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('gSRkHpB7Bu3D', 'pOFVzbXLmzhX', 'R6pheWjdwmNU', 2, null, 0, 0, '2017-12-23T03:54:46.138Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('6brdjeWDOB6w', '0xtvjqrcGiRB', 'ZC78NlmdXeC6', 0, null, 0, 0, '2017-12-23T04:02:06.650Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('AqKUM2zUVFUF', 'Zl69uXBSen0w', 'ZC78NlmdXeC6', 2, null, 1, 0, '2017-12-23T04:02:16.685Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('Ez7NN2WVzRc4', '62BKAQMVP2KW', 'Zl69uXBSen0w', 1, null, 0, 0, '2017-12-23T04:02:39.164Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('t3vVElqMIQVa', 'h4OfLEAYspud', 'WdWZFuWNVDZk', 2, null, 1, 0, '2017-12-23T04:06:25.769Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('O983DHtLpgmr', '1hASbLRDL7oo', 'h4OfLEAYspud', 0, null, 0, 0, '2017-12-23T16:42:26.347Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('RsvL795Mk1bp', '1hASbLRDL7oo', 'GpGnjmcAPeWG', 1, '', 0, 0, '2017-12-23T04:04:56.830Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('79e4hrHLFmx6', 'jyqG9GucsMdn', 'Iha4YwchR413', 1, null, 0, 0, '2017-12-23T04:05:16.439Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('oWO8rctUjf7d', 'WdWZFuWNVDZk', '1Heh2acXfPNt', 5, null, 1, 0, '2017-12-23T04:06:16.179Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('GOxcrZrxalFN', 'yK4SBJfwD3tY', '1Heh2acXfPNt', 8, null, 1, 0, '2017-12-23T04:06:32.833Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('bSPmEvjLzQKU', 'r4BnsmSQeVr1', 'yK4SBJfwD3tY', 0, null, 0, 0, '2017-12-23T04:06:37.427Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('bMtxCD6cwNR9', 'QbL3pTvhgzM8', 'yK4SBJfwD3tY', 2, null, 0, 0, '2017-12-23T04:06:43.841Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('o4ycR7xIi4oI', 'moMbTKwN15Ps', 'yK4SBJfwD3tY', 3, null, 1, 0, '2017-12-23T04:06:49.331Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('abTEhnOsAsSg', 'PEGQGg0In3Ar', 'GpGnjmcAPeWG', 2, null, 0, 0, '2017-12-23T16:44:35.900Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('bryQseMhyzaI', 'IlULcDiOTI4K', '1Heh2acXfPNt', 0, null, 0, 0, '2017-12-23T18:04:26.439Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('ccslPJf3wQV3', 'vBv6ovBupfTj', 'IlULcDiOTI4K', 0, null, 0, 0, '2017-12-23T18:04:50.904Z');
-INSERT INTO notes_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('5Dt9YCMn59sY', 'mw4f2xB4J5fV', 'IlULcDiOTI4K', 1, null, 0, 0, '2017-12-23T18:05:24.868Z');
\ No newline at end of file
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('dLgtLUFn3GoN', '1Heh2acXfPNt', 'root', 21, null, 1, 0, '2017-12-23T00:46:39.304Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('QLfS835GSfIh', '3RkyK9LI18dO', '1Heh2acXfPNt', 1, null, 1, 0, '2017-12-23T01:20:04.181Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('QJAcYJ1gGUh9', 'L1Ox40M1aEyy', '3RkyK9LI18dO', 0, null, 0, 0, '2017-12-23T01:20:45.365Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('wLTa2l3lYi83', 'HJusZTbBU494', '3RkyK9LI18dO', 2, null, 1, 0, '2017-12-23T01:20:50.709Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('yMhwsE7uvEij', '3oldoiMUPOlr', 'HJusZTbBU494', 1, null, 1, 0, '2017-12-23T01:20:55.775Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('EjQTcVVHFmmZ', 'MG0wntwILQW6', '3oldoiMUPOlr', 1, null, 1, 0, '2017-12-23T01:21:10.517Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('jvhKcwz4pYTr', 'ZC78NlmdXeC6', 'WdWZFuWNVDZk', 0, null, 1, 0, '2017-12-23T04:06:21.579Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('CarTrwkGVcPz', 'NncfGH8dyNjJ', 'WdWZFuWNVDZk', 1, null, 0, 0, '2017-12-23T04:06:24.012Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('6M7qPlr7at6N', 'eouCLkjbruai', 'NncfGH8dyNjJ', 0, null, 0, 0, '2017-12-23T01:23:28.291Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('tQgognnAH9WI', 'C44aq4mkaX67', 'NncfGH8dyNjJ', 1, null, 0, 0, '2017-12-23T01:23:31.879Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('xyAi7MmgvAgR', 'C44aq4mkaX67', 'ZC78NlmdXeC6', 1, null, 0, 0, '2017-12-23T01:23:47.756Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('xQ3fjRp9yaPq', 'I6Cw88AirBBl', 'C44aq4mkaX67', 0, null, 0, 0, '2017-12-23T01:24:04.681Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('2GOsNT5LsvTP', 'mcEwFMSjhlvL', 'C44aq4mkaX67', 1, null, 0, 0, '2017-12-23T01:29:35.974Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('RxUiraiR655R', 'CF2lUIJAr6Ey', 'NncfGH8dyNjJ', 2, null, 0, 0, '2017-12-23T01:34:37.658Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('mZuSrZ18Zmv0', 'xkXwueRoDNeN', 'MG0wntwILQW6', 0, null, 0, 0, '2017-12-23T01:35:40.306Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('hbcWTnEnXPwF', 'eXHZAKsMYgur', '1Heh2acXfPNt', 3, null, 1, 0, '2017-12-23T03:32:42.868Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('8a3aNxjG0nu7', '2WU27ekfy07E', 'eXHZAKsMYgur', 0, null, 0, 0, '2017-12-23T03:32:49.379Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('4Tu6vaPdCxCM', 'TjWEndYCCg7g', 'eXHZAKsMYgur', 1, null, 0, 0, '2017-12-23T03:33:23.584Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('lBPOmhP12egP', '8nRNDJGyGs2Z', 'TjWEndYCCg7g', 0, null, 0, 0, '2017-12-23T03:33:37.327Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('C5ipVqeDWySp', '9zSwD89vgzNO', '8nRNDJGyGs2Z', 0, null, 0, 0, '2017-12-23T03:37:04.912Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('uSitzbGcSATJ', 'u5t1EvWa3CMO', 'TjWEndYCCg7g', 1, null, 0, 0, '2017-12-23T03:39:21.918Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('GZ6aRI8rdSJt', '8nRNDJGyGs2Z', 'MG0wntwILQW6', 1, '', 0, 0, '2017-12-23T03:42:28.310Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('HsN4600rQoL9', 'Iha4YwchR413', '3oldoiMUPOlr', 0, null, 1, 0, '2017-12-23T03:44:30.945Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('uipfvAfwWRgx', '6ZuXjCSWgjB4', 'HJusZTbBU494', 0, null, 0, 0, '2017-12-23T03:44:54.096Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('nMRpPWWH8WRk', 'GpGnjmcAPeWG', '6ZuXjCSWgjB4', 0, null, 1, 0, '2017-12-23T03:44:57.036Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('c4wt27WNjepw', '21K84UqGhqlt', 'GpGnjmcAPeWG', 0, null, 0, 0, '2017-12-23T03:45:10.933Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('0fpnraUGs9Kl', 'rz5t0r9Qr2WC', 'HJusZTbBU494', 2, null, 1, 0, '2017-12-23T03:45:20.914Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('d8L8zYlLTbym', 'R6pheWjdwmNU', 'rz5t0r9Qr2WC', 0, null, 1, 0, '2017-12-23T03:45:28.002Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('T4USGzfllu5t', '5v5Dx6LMHXIO', 'Iha4YwchR413', 0, null, 0, 0, '2017-12-23T03:45:44.184Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('c4JgFNIobvQW', 'MLQjmREtcnJ3', 'R6pheWjdwmNU', 0, null, 0, 0, '2017-12-23T03:47:48.208Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('nfWjptAU2ZDg', 'pTTjrxgnvURB', 'R6pheWjdwmNU', 1, null, 0, 0, '2017-12-23T03:47:55.932Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('T2ToYBfyPy0g', 'cFK9sGYZaMWs', 'rz5t0r9Qr2WC', 1, null, 0, 0, '2017-12-23T03:49:32.210Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('NG4gbKOnsM3v', '21K84UqGhqlt', 'MLQjmREtcnJ3', 0, '28. 11. 2017', 0, 0, '2017-12-23T03:53:38.110Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('Fstg4tkccO4N', '5v5Dx6LMHXIO', 'MLQjmREtcnJ3', 1, '21. 12. 2017', 0, 0, '2017-12-23T03:53:49.737Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('MN8B7qXDUViO', 'xkXwueRoDNeN', 'MLQjmREtcnJ3', 2, '22. 12. 2017', 0, 0, '2017-12-23T03:53:57.486Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('gSRkHpB7Bu3D', 'pOFVzbXLmzhX', 'R6pheWjdwmNU', 2, null, 0, 0, '2017-12-23T03:54:46.138Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('6brdjeWDOB6w', '0xtvjqrcGiRB', 'ZC78NlmdXeC6', 0, null, 0, 0, '2017-12-23T04:02:06.650Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('AqKUM2zUVFUF', 'Zl69uXBSen0w', 'ZC78NlmdXeC6', 2, null, 1, 0, '2017-12-23T04:02:16.685Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('Ez7NN2WVzRc4', '62BKAQMVP2KW', 'Zl69uXBSen0w', 1, null, 0, 0, '2017-12-23T04:02:39.164Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('t3vVElqMIQVa', 'h4OfLEAYspud', 'WdWZFuWNVDZk', 2, null, 1, 0, '2017-12-23T04:06:25.769Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('O983DHtLpgmr', '1hASbLRDL7oo', 'h4OfLEAYspud', 0, null, 0, 0, '2017-12-23T16:42:26.347Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('RsvL795Mk1bp', '1hASbLRDL7oo', 'GpGnjmcAPeWG', 1, '', 0, 0, '2017-12-23T04:04:56.830Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('79e4hrHLFmx6', 'jyqG9GucsMdn', 'Iha4YwchR413', 1, null, 0, 0, '2017-12-23T04:05:16.439Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('oWO8rctUjf7d', 'WdWZFuWNVDZk', '1Heh2acXfPNt', 5, null, 1, 0, '2017-12-23T04:06:16.179Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('GOxcrZrxalFN', 'yK4SBJfwD3tY', '1Heh2acXfPNt', 8, null, 1, 0, '2017-12-23T04:06:32.833Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('bSPmEvjLzQKU', 'r4BnsmSQeVr1', 'yK4SBJfwD3tY', 0, null, 0, 0, '2017-12-23T04:06:37.427Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('bMtxCD6cwNR9', 'QbL3pTvhgzM8', 'yK4SBJfwD3tY', 2, null, 0, 0, '2017-12-23T04:06:43.841Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('o4ycR7xIi4oI', 'moMbTKwN15Ps', 'yK4SBJfwD3tY', 3, null, 1, 0, '2017-12-23T04:06:49.331Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('abTEhnOsAsSg', 'PEGQGg0In3Ar', 'GpGnjmcAPeWG', 2, null, 0, 0, '2017-12-23T16:44:35.900Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('bryQseMhyzaI', 'IlULcDiOTI4K', '1Heh2acXfPNt', 0, null, 0, 0, '2017-12-23T18:04:26.439Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('ccslPJf3wQV3', 'vBv6ovBupfTj', 'IlULcDiOTI4K', 0, null, 0, 0, '2017-12-23T18:04:50.904Z');
+INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified) VALUES ('5Dt9YCMn59sY', 'mw4f2xB4J5fV', 'IlULcDiOTI4K', 1, null, 0, 0, '2017-12-23T18:05:24.868Z');
\ No newline at end of file
diff --git a/public/javascripts/dialogs/note_history.js b/public/javascripts/dialogs/note_history.js
index 79453159a7..f92a66a136 100644
--- a/public/javascripts/dialogs/note_history.js
+++ b/public/javascripts/dialogs/note_history.js
@@ -12,7 +12,7 @@ const noteHistory = (function() {
await showNoteHistoryDialog(noteEditor.getCurrentNoteId());
}
- async function showNoteHistoryDialog(noteId, noteHistoryId) {
+ async function showNoteHistoryDialog(noteId, noteRevisionId) {
glob.activeDialog = dialogEl;
dialogEl.dialog({
@@ -30,17 +30,17 @@ const noteHistory = (function() {
const dateModified = parseDate(item.dateModifiedFrom);
listEl.append($('<option>', {
- value: item.noteHistoryId,
+ value: item.noteRevisionId,
text: formatDateTime(dateModified)
}));
}
if (historyItems.length > 0) {
- if (!noteHistoryId) {
- noteHistoryId = listEl.find("option:first").val();
+ if (!noteRevisionId) {
+ noteRevisionId = listEl.find("option:first").val();
}
- listEl.val(noteHistoryId).trigger('change');
+ listEl.val(noteRevisionId).trigger('change');
}
else {
titleEl.text("No history for this note yet...");
@@ -56,7 +56,7 @@ const noteHistory = (function() {
listEl.on('change', () => {
const optVal = listEl.find(":selected").val();
- const historyItem = historyItems.find(r => r.noteHistoryId === optVal);
+ const historyItem = historyItems.find(r => r.noteRevisionId === optVal);
titleEl.html(historyItem.title);
contentEl.html(historyItem.content);
@@ -65,9 +65,9 @@ const noteHistory = (function() {
$(document).on('click', "a[action='note-history']", event => {
const linkEl = $(event.target);
const noteId = linkEl.attr('note-path');
- const noteHistoryId = linkEl.attr('note-history-id');
+ const noteRevisionId = linkEl.attr('note-history-id');
- showNoteHistoryDialog(noteId, noteHistoryId);
+ showNoteHistoryDialog(noteId, noteRevisionId);
return false;
});
diff --git a/public/javascripts/dialogs/recent_changes.js b/public/javascripts/dialogs/recent_changes.js
index c7959e8470..c7f98800ea 100644
--- a/public/javascripts/dialogs/recent_changes.js
+++ b/public/javascripts/dialogs/recent_changes.js
@@ -31,7 +31,7 @@ const recentChanges = (function() {
text: 'rev'
}).attr('action', 'note-history')
.attr('note-path', change.noteId)
- .attr('note-history-id', change.noteHistoryId);
+ .attr('note-history-id', change.noteRevisionId);
let noteLink;
diff --git a/public/javascripts/messaging.js b/public/javascripts/messaging.js
index 441d8bcc89..415047e602 100644
--- a/public/javascripts/messaging.js
+++ b/public/javascripts/messaging.js
@@ -29,7 +29,7 @@ const messaging = (function() {
const syncData = message.data.filter(sync => sync.sourceId !== glob.sourceId);
- if (syncData.some(sync => sync.entityName === 'notes_tree')
+ if (syncData.some(sync => sync.entityName === 'note_tree')
|| syncData.some(sync => sync.entityName === 'notes')) {
console.log(now(), "Reloading tree because of background changes");
diff --git a/routes/api/cleanup.js b/routes/api/cleanup.js
index c0c1198951..c52f3d24b3 100644
--- a/routes/api/cleanup.js
+++ b/routes/api/cleanup.js
@@ -18,15 +18,15 @@ router.post('/cleanup-soft-deleted-items', auth.checkApiAuth, wrap(async (req, r
await sql.execute(`DELETE FROM event_log WHERE noteId IN (${noteIdsSql})`);
- await sql.execute(`DELETE FROM notes_history WHERE noteId IN (${noteIdsSql})`);
+ await sql.execute(`DELETE FROM note_revisions WHERE noteId IN (${noteIdsSql})`);
- await sql.execute(`DELETE FROM notes_image WHERE noteId IN (${noteIdsSql})`);
+ await sql.execute(`DELETE FROM note_images WHERE noteId IN (${noteIdsSql})`);
await sql.execute(`DELETE FROM attributes WHERE noteId IN (${noteIdsSql})`);
- await sql.execute("DELETE FROM notes_tree WHERE isDeleted = 1");
+ await sql.execute("DELETE FROM note_tree WHERE isDeleted = 1");
- await sql.execute("DELETE FROM notes_image WHERE isDeleted = 1");
+ await sql.execute("DELETE FROM note_images WHERE isDeleted = 1");
await sql.execute("DELETE FROM images WHERE isDeleted = 1");
@@ -35,8 +35,8 @@ router.post('/cleanup-soft-deleted-items', auth.checkApiAuth, wrap(async (req, r
await sql.execute("DELETE FROM recent_notes");
await sync_table.cleanupSyncRowsForMissingEntities("notes", "noteId");
- await sync_table.cleanupSyncRowsForMissingEntities("notes_tree", "noteTreeId");
- await sync_table.cleanupSyncRowsForMissingEntities("notes_history", "noteHistoryId");
+ await sync_table.cleanupSyncRowsForMissingEntities("note_tree", "noteTreeId");
+ await sync_table.cleanupSyncRowsForMissingEntities("note_revisions", "noteRevisionId");
await sync_table.cleanupSyncRowsForMissingEntities("recent_notes", "noteTreeId");
log.info("Following notes has been completely cleaned from database: " + noteIdsSql);
@@ -52,10 +52,10 @@ router.post('/cleanup-unused-images', auth.checkApiAuth, wrap(async (req, res, n
const unusedImageIds = await sql.getFirstColumn(`
SELECT images.imageId
FROM images
- LEFT JOIN notes_image ON notes_image.imageId = images.imageId AND notes_image.isDeleted = 0
+ LEFT JOIN note_images ON note_images.imageId = images.imageId AND note_images.isDeleted = 0
WHERE
images.isDeleted = 0
- AND notes_image.noteImageId IS NULL`);
+ AND note_images.noteImageId IS NULL`);
const now = utils.nowDate();
diff --git a/routes/api/cloning.js b/routes/api/cloning.js
index c97ce8d734..e8d6bc509d 100644
--- a/routes/api/cloning.js
+++ b/routes/api/cloning.js
@@ -19,7 +19,7 @@ router.put('/:childNoteId/clone-to/:parentNoteId', auth.checkApiAuth, wrap(async
return;
}
- const maxNotePos = await sql.getFirstValue('SELECT MAX(notePosition) FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
+ const maxNotePos = await sql.getFirstValue('SELECT MAX(notePosition) FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
await sql.doInTransaction(async () => {
@@ -34,11 +34,11 @@ router.put('/:childNoteId/clone-to/:parentNoteId', auth.checkApiAuth, wrap(async
isDeleted: 0
};
- await sql.replace("notes_tree", noteTree);
+ await sql.replace("note_tree", noteTree);
await sync_table.addNoteTreeSync(noteTree.noteTreeId, sourceId);
- await sql.execute("UPDATE notes_tree SET isExpanded = 1 WHERE noteId = ?", [parentNoteId]);
+ await sql.execute("UPDATE note_tree SET isExpanded = 1 WHERE noteId = ?", [parentNoteId]);
});
res.send({ success: true });
@@ -58,7 +58,7 @@ router.put('/:noteId/clone-after/:afterNoteTreeId', auth.checkApiAuth, wrap(asyn
await sql.doInTransaction(async () => {
// we don't change dateModified so other changes are prioritized in case of conflict
// also we would have to sync all those modified note trees otherwise hash checks would fail
- await sql.execute("UPDATE notes_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
+ await sql.execute("UPDATE note_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
[afterNote.parentNoteId, afterNote.notePosition]);
await sync_table.addNoteReorderingSync(afterNote.parentNoteId, sourceId);
@@ -73,7 +73,7 @@ router.put('/:noteId/clone-after/:afterNoteTreeId', auth.checkApiAuth, wrap(asyn
isDeleted: 0
};
- await sql.replace("notes_tree", noteTree);
+ await sql.replace("note_tree", noteTree);
await sync_table.addNoteTreeSync(noteTree.noteTreeId, sourceId);
});
diff --git a/routes/api/export.js b/routes/api/export.js
index b0502ac007..637a2a5948 100644
--- a/routes/api/export.js
+++ b/routes/api/export.js
@@ -26,7 +26,7 @@ router.get('/:noteId/to/:directory', auth.checkApiAuth, wrap(async (req, res, ne
fs.mkdirSync(completeExportDir);
- const noteTreeId = await sql.getFirstValue('SELECT noteTreeId FROM notes_tree WHERE noteId = ?', [noteId]);
+ const noteTreeId = await sql.getFirstValue('SELECT noteTreeId FROM note_tree WHERE noteId = ?', [noteId]);
await exportNote(noteTreeId, completeExportDir);
@@ -34,14 +34,14 @@ router.get('/:noteId/to/:directory', auth.checkApiAuth, wrap(async (req, res, ne
}));
async function exportNote(noteTreeId, dir) {
- const noteTree = await sql.getFirst("SELECT * FROM notes_tree WHERE noteTreeId = ?", [noteTreeId]);
+ const noteTree = await sql.getFirst("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]);
const note = await sql.getFirst("SELECT * FROM notes WHERE noteId = ?", [noteTree.noteId]);
const pos = (noteTree.notePosition + '').padStart(4, '0');
fs.writeFileSync(dir + '/' + pos + '-' + note.title + '.html', html.prettyPrint(note.content, {indent_size: 2}));
- const children = await sql.getAll("SELECT * FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0", [note.noteId]);
+ const children = await sql.getAll("SELECT * FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [note.noteId]);
if (children.length > 0) {
const childrenDir = dir + '/' + pos + '-' + note.title;
diff --git a/routes/api/image.js b/routes/api/image.js
index c1f6a2244e..9d6a52b6d8 100644
--- a/routes/api/image.js
+++ b/routes/api/image.js
@@ -77,7 +77,7 @@ router.post('', auth.checkApiAuthOrElectron, multer.single('upload'), wrap(async
const noteImageId = utils.newNoteImageId();
- await sql.insert("notes_image", {
+ await sql.insert("note_images", {
noteImageId: noteImageId,
noteId: noteId,
imageId: imageId,
diff --git a/routes/api/import.js b/routes/api/import.js
index 1c0543fd13..0325c8cdbf 100644
--- a/routes/api/import.js
+++ b/routes/api/import.js
@@ -52,7 +52,7 @@ async function importNotes(dir, parentNoteId) {
noteTitle = match[2];
}
else {
- let maxPos = await sql.getFirstValue("SELECT MAX(notePosition) FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]);
+ let maxPos = await sql.getFirstValue("SELECT MAX(notePosition) FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]);
if (maxPos) {
notePos = maxPos + 1;
}
@@ -66,11 +66,11 @@ async function importNotes(dir, parentNoteId) {
const noteText = fs.readFileSync(path, "utf8");
const noteId = utils.newNoteId();
- const noteTreeId = utils.newNoteHistoryId();
+ const noteTreeId = utils.newnoteRevisionId();
const now = utils.nowDate();
- await sql.insert('notes_tree', {
+ await sql.insert('note_tree', {
noteTreeId: noteTreeId,
noteId: noteId,
parentNoteId: parentNoteId,
diff --git a/routes/api/note_history.js b/routes/api/note_history.js
index 06a29649e7..fcbb7a362e 100644
--- a/routes/api/note_history.js
+++ b/routes/api/note_history.js
@@ -10,7 +10,7 @@ const wrap = require('express-promise-wrap').wrap;
router.get('/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {
const noteId = req.params.noteId;
- const history = await sql.getAll("SELECT * FROM notes_history WHERE noteId = ? order by dateModifiedTo desc", [noteId]);
+ const history = await sql.getAll("SELECT * FROM note_revisions WHERE noteId = ? order by dateModifiedTo desc", [noteId]);
protected_session.decryptNoteHistoryRows(req, history);
res.send(history);
@@ -20,9 +20,9 @@ router.put('', auth.checkApiAuth, wrap(async (req, res, next) => {
const sourceId = req.headers.sourceId;
await sql.doInTransaction(async () => {
- await sql.replace("notes_history", req.body);
+ await sql.replace("note_revisions", req.body);
- await sync_table.addNoteHistorySync(req.body.noteHistoryId, sourceId);
+ await sync_table.addNoteHistorySync(req.body.noteRevisionId, sourceId);
});
res.send();
diff --git a/routes/api/recent_changes.js b/routes/api/recent_changes.js
index 11b41920d9..34a394f72b 100644
--- a/routes/api/recent_changes.js
+++ b/routes/api/recent_changes.js
@@ -11,9 +11,9 @@ router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
`SELECT
notes.isDeleted AS current_isDeleted,
notes.title AS current_title,
- notes_history.*
+ note_revisions.*
FROM
- notes_history
+ note_revisions
JOIN notes USING(noteId)
ORDER BY
dateModifiedTo DESC
diff --git a/routes/api/recent_notes.js b/routes/api/recent_notes.js
index 66b4f343f0..bfb0d81f8d 100644
--- a/routes/api/recent_notes.js
+++ b/routes/api/recent_notes.js
@@ -40,10 +40,10 @@ async function getRecentNotes() {
recent_notes.*
FROM
recent_notes
- JOIN notes_tree USING(noteTreeId)
+ JOIN note_tree USING(noteTreeId)
WHERE
recent_notes.isDeleted = 0
- AND notes_tree.isDeleted = 0
+ AND note_tree.isDeleted = 0
ORDER BY
dateAccessed DESC`);
}
diff --git a/routes/api/script.js b/routes/api/script.js
index c9d02e9753..d53e2ee57b 100644
--- a/routes/api/script.js
+++ b/routes/api/script.js
@@ -50,9 +50,9 @@ async function getNoteWithSubtreeScript(noteId, req) {
async function getSubTreeScripts(parentId, includedNoteIds, dataKey) {
const children = await sql.getAll(`SELECT notes.noteId, notes.title, notes.content, notes.isProtected, notes.mime
- FROM notes JOIN notes_tree USING(noteId)
- WHERE notes_tree.isDeleted = 0 AND notes.isDeleted = 0
- AND notes_tree.parentNoteId = ? AND notes.type = 'code'
+ FROM notes JOIN note_tree USING(noteId)
+ WHERE note_tree.isDeleted = 0 AND notes.isDeleted = 0
+ AND note_tree.parentNoteId = ? AND notes.type = 'code'
AND (notes.mime = 'application/javascript' OR notes.mime = 'text/html')`, [parentId]);
protected_session.decryptNotes(dataKey, children);
diff --git a/routes/api/sync.js b/routes/api/sync.js
index 94873f57a3..0491c9cbb4 100644
--- a/routes/api/sync.js
+++ b/routes/api/sync.js
@@ -53,13 +53,13 @@ router.post('/force-note-sync/:noteId', auth.checkApiAuth, wrap(async (req, res,
await sql.doInTransaction(async () => {
await sync_table.addNoteSync(noteId);
- for (const noteTreeId of await sql.getFirstColumn("SELECT noteTreeId FROM notes_tree WHERE isDeleted = 0 AND noteId = ?", [noteId])) {
+ for (const noteTreeId of await sql.getFirstColumn("SELECT noteTreeId FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [noteId])) {
await sync_table.addNoteTreeSync(noteTreeId);
await sync_table.addRecentNoteSync(noteTreeId);
}
- for (const noteHistoryId of await sql.getFirstColumn("SELECT noteHistoryId FROM notes_history WHERE noteId = ?", [noteId])) {
- await sync_table.addNoteHistorySync(noteHistoryId);
+ for (const noteRevisionId of await sql.getFirstColumn("SELECT noteRevisionId FROM note_revisions WHERE noteId = ?", [noteId])) {
+ await sync_table.addNoteHistorySync(noteRevisionId);
}
});
@@ -85,16 +85,16 @@ router.get('/notes/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {
});
}));
-router.get('/notes_tree/:noteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
+router.get('/note_tree/:noteTreeId', auth.checkApiAuth, wrap(async (req, res, next) => {
const noteTreeId = req.params.noteTreeId;
- res.send(await sql.getFirst("SELECT * FROM notes_tree WHERE noteTreeId = ?", [noteTreeId]));
+ res.send(await sql.getFirst("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]));
}));
-router.get('/notes_history/:noteHistoryId', auth.checkApiAuth, wrap(async (req, res, next) => {
- const noteHistoryId = req.params.noteHistoryId;
+router.get('/note_revisions/:noteRevisionId', auth.checkApiAuth, wrap(async (req, res, next) => {
+ const noteRevisionId = req.params.noteRevisionId;
- res.send(await sql.getFirst("SELECT * FROM notes_history WHERE noteHistoryId = ?", [noteHistoryId]));
+ res.send(await sql.getFirst("SELECT * FROM note_revisions WHERE noteRevisionId = ?", [noteRevisionId]));
}));
router.get('/options/:name', auth.checkApiAuth, wrap(async (req, res, next) => {
@@ -114,7 +114,7 @@ router.get('/notes_reordering/:parentNoteId', auth.checkApiAuth, wrap(async (req
res.send({
parentNoteId: parentNoteId,
- ordering: await sql.getMap("SELECT noteTreeId, notePosition FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId])
+ ordering: await sql.getMap("SELECT noteTreeId, notePosition FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId])
});
}));
@@ -135,10 +135,10 @@ router.get('/images/:imageId', auth.checkApiAuth, wrap(async (req, res, next) =>
res.send(entity);
}));
-router.get('/notes_image/:noteImageId', auth.checkApiAuth, wrap(async (req, res, next) => {
+router.get('/note_images/:noteImageId', auth.checkApiAuth, wrap(async (req, res, next) => {
const noteImageId = req.params.noteImageId;
- res.send(await sql.getFirst("SELECT * FROM notes_image WHERE noteImageId = ?", [noteImageId]));
+ res.send(await sql.getFirst("SELECT * FROM note_images WHERE noteImageId = ?", [noteImageId]));
}));
router.get('/attributes/:attributeId', auth.checkApiAuth, wrap(async (req, res, next) => {
@@ -153,13 +153,13 @@ router.put('/notes', auth.checkApiAuth, wrap(async (req, res, next) => {
res.send({});
}));
-router.put('/notes_tree', auth.checkApiAuth, wrap(async (req, res, next) => {
+router.put('/note_tree', auth.checkApiAuth, wrap(async (req, res, next) => {
await syncUpdate.updateNoteTree(req.body.entity, req.body.sourceId);
res.send({});
}));
-router.put('/notes_history', auth.checkApiAuth, wrap(async (req, res, next) => {
+router.put('/note_revisions', auth.checkApiAuth, wrap(async (req, res, next) => {
await syncUpdate.updateNoteHistory(req.body.entity, req.body.sourceId);
res.send({});
@@ -189,7 +189,7 @@ router.put('/images', auth.checkApiAuth, wrap(async (req, res, next) => {
res.send({});
}));
-router.put('/notes_image', auth.checkApiAuth, wrap(async (req, res, next) => {
+router.put('/note_images', auth.checkApiAuth, wrap(async (req, res, next) => {
await syncUpdate.updateNoteImage(req.body.entity, req.body.sourceId);
res.send({});
diff --git a/routes/api/tree.js b/routes/api/tree.js
index 2beea3dce1..13c4a1174b 100644
--- a/routes/api/tree.js
+++ b/routes/api/tree.js
@@ -13,17 +13,17 @@ const wrap = require('express-promise-wrap').wrap;
router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
const notes = await sql.getAll(`
SELECT
- notes_tree.*,
+ note_tree.*,
notes.title,
notes.isProtected,
notes.type
FROM
- notes_tree
+ note_tree
JOIN
- notes ON notes.noteId = notes_tree.noteId
+ notes ON notes.noteId = note_tree.noteId
WHERE
notes.isDeleted = 0
- AND notes_tree.isDeleted = 0
+ AND note_tree.isDeleted = 0
ORDER BY
notePosition`);
@@ -41,7 +41,7 @@ router.put('/:noteTreeId/set-prefix', auth.checkApiAuth, wrap(async (req, res, n
const prefix = utils.isEmptyOrWhitespace(req.body.prefix) ? null : req.body.prefix;
await sql.doInTransaction(async () => {
- await sql.execute("UPDATE notes_tree SET prefix = ?, dateModified = ? WHERE noteTreeId = ?", [prefix, utils.nowDate(), noteTreeId]);
+ await sql.execute("UPDATE note_tree SET prefix = ?, dateModified = ? WHERE noteTreeId = ?", [prefix, utils.nowDate(), noteTreeId]);
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
});
diff --git a/routes/api/tree_changes.js b/routes/api/tree_changes.js
index 8dbe5a50a4..7867159c1f 100644
--- a/routes/api/tree_changes.js
+++ b/routes/api/tree_changes.js
@@ -26,13 +26,13 @@ router.put('/:noteTreeId/move-to/:parentNoteId', auth.checkApiAuth, wrap(async (
return;
}
- const maxNotePos = await sql.getFirstValue('SELECT MAX(notePosition) FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
+ const maxNotePos = await sql.getFirstValue('SELECT MAX(notePosition) FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
const now = utils.nowDate();
await sql.doInTransaction(async () => {
- await sql.execute("UPDATE notes_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
+ await sql.execute("UPDATE note_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
[parentNoteId, newNotePos, now, noteTreeId]);
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
@@ -56,14 +56,14 @@ router.put('/:noteTreeId/move-before/:beforeNoteTreeId', auth.checkApiAuth, wrap
await sql.doInTransaction(async () => {
// we don't change dateModified so other changes are prioritized in case of conflict
// also we would have to sync all those modified note trees otherwise hash checks would fail
- await sql.execute("UPDATE notes_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition >= ? AND isDeleted = 0",
+ await sql.execute("UPDATE note_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition >= ? AND isDeleted = 0",
[beforeNote.parentNoteId, beforeNote.notePosition]);
await sync_table.addNoteReorderingSync(beforeNote.parentNoteId, sourceId);
const now = utils.nowDate();
- await sql.execute("UPDATE notes_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
+ await sql.execute("UPDATE note_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
[beforeNote.parentNoteId, beforeNote.notePosition, now, noteTreeId]);
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
@@ -87,12 +87,12 @@ router.put('/:noteTreeId/move-after/:afterNoteTreeId', auth.checkApiAuth, wrap(a
await sql.doInTransaction(async () => {
// we don't change dateModified so other changes are prioritized in case of conflict
// also we would have to sync all those modified note trees otherwise hash checks would fail
- await sql.execute("UPDATE notes_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
+ await sql.execute("UPDATE note_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
[afterNote.parentNoteId, afterNote.notePosition]);
await sync_table.addNoteReorderingSync(afterNote.parentNoteId, sourceId);
- await sql.execute("UPDATE notes_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
+ await sql.execute("UPDATE note_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
[afterNote.parentNoteId, afterNote.notePosition + 1, utils.nowDate(), noteTreeId]);
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
@@ -106,7 +106,7 @@ router.put('/:noteTreeId/expanded/:expanded', auth.checkApiAuth, wrap(async (req
const expanded = req.params.expanded;
await sql.doInTransaction(async () => {
- await sql.execute("UPDATE notes_tree SET isExpanded = ? WHERE noteTreeId = ?", [expanded, noteTreeId]);
+ await sql.execute("UPDATE note_tree SET isExpanded = ? WHERE noteTreeId = ?", [expanded, noteTreeId]);
// we don't sync expanded attribute
});
diff --git a/services/anonymization.js b/services/anonymization.js
index 91f4e3f7e2..2f08d6057e 100644
--- a/services/anonymization.js
+++ b/services/anonymization.js
@@ -17,8 +17,8 @@ async function anonymize() {
const db = await sqlite.open(anonymizedFile, {Promise});
await db.run("UPDATE notes SET title = 'title', content = 'text'");
- await db.run("UPDATE notes_history SET title = 'title', content = 'text'");
- await db.run("UPDATE notes_tree SET prefix = 'prefix' WHERE prefix IS NOT NULL");
+ await db.run("UPDATE note_revisions SET title = 'title', content = 'text'");
+ await db.run("UPDATE note_tree SET prefix = 'prefix' WHERE prefix IS NOT NULL");
await db.run(`UPDATE options SET value = 'anonymized' WHERE name IN
('document_secret', 'encrypted_data_key', 'password_verification_hash',
'password_verification_salt', 'password_derived_key_salt')`);
diff --git a/services/consistency_checks.js b/services/consistency_checks.js
index e228e8d1d3..229a62e529 100644
--- a/services/consistency_checks.js
+++ b/services/consistency_checks.js
@@ -23,7 +23,7 @@ async function runCheck(query, errorText, errorList) {
async function checkTreeCycles(errorList) {
const childToParents = {};
- const rows = await sql.getAll("SELECT noteId, parentNoteId FROM notes_tree WHERE isDeleted = 0");
+ const rows = await sql.getAll("SELECT noteId, parentNoteId FROM note_tree WHERE isDeleted = 0");
for (const row of rows) {
const childNoteId = row.noteId;
@@ -92,17 +92,17 @@ async function runAllChecks() {
noteId
FROM
notes
- LEFT JOIN notes_tree USING(noteId)
+ LEFT JOIN note_tree USING(noteId)
WHERE
noteId != 'root'
- AND notes_tree.noteTreeId IS NULL`,
- "Missing notes_tree records for following note IDs", errorList);
+ AND note_tree.noteTreeId IS NULL`,
+ "Missing note_tree records for following note IDs", errorList);
await runCheck(`
SELECT
- noteTreeId || ' > ' || notes_tree.noteId
+ noteTreeId || ' > ' || note_tree.noteId
FROM
- notes_tree
+ note_tree
LEFT JOIN notes USING(noteId)
WHERE
notes.noteId IS NULL`,
@@ -112,22 +112,22 @@ async function runAllChecks() {
SELECT
noteTreeId
FROM
- notes_tree
+ note_tree
JOIN notes USING(noteId)
WHERE
notes.isDeleted = 1
- AND notes_tree.isDeleted = 0`,
+ AND note_tree.isDeleted = 0`,
"Note tree is not deleted even though main note is deleted for following note tree IDs", errorList);
await runCheck(`
SELECT
child.noteTreeId
FROM
- notes_tree AS child
+ note_tree AS child
WHERE
child.isDeleted = 0
AND child.parentNoteId != 'root'
- AND (SELECT COUNT(*) FROM notes_tree AS parent WHERE parent.noteId = child.parentNoteId
+ AND (SELECT COUNT(*) FROM note_tree AS parent WHERE parent.noteId = child.parentNoteId
AND parent.isDeleted = 0) = 0`,
"All parent note trees are deleted but child note tree is not for these child note tree IDs", errorList);
@@ -137,18 +137,18 @@ async function runAllChecks() {
DISTINCT noteId
FROM
notes
- JOIN notes_tree USING(noteId)
+ JOIN note_tree USING(noteId)
WHERE
- (SELECT COUNT(*) FROM notes_tree WHERE notes.noteId = notes_tree.noteId AND notes_tree.isDeleted = 0) = 0
+ (SELECT COUNT(*) FROM note_tree WHERE notes.noteId = note_tree.noteId AND note_tree.isDeleted = 0) = 0
AND notes.isDeleted = 0
`, 'No undeleted note trees for note IDs', errorList);
await runCheck(`
SELECT
child.parentNoteId || ' > ' || child.noteId
- FROM notes_tree
+ FROM note_tree
AS child
- LEFT JOIN notes_tree AS parent ON parent.noteId = child.parentNoteId
+ LEFT JOIN note_tree AS parent ON parent.noteId = child.parentNoteId
WHERE
parent.noteId IS NULL
AND child.parentNoteId != 'root'`,
@@ -156,23 +156,23 @@ async function runAllChecks() {
await runCheck(`
SELECT
- noteHistoryId || ' > ' || notes_history.noteId
+ noteRevisionId || ' > ' || note_revisions.noteId
FROM
- notes_history LEFT JOIN notes USING(noteId)
+ note_revisions LEFT JOIN notes USING(noteId)
WHERE
notes.noteId IS NULL`,
"Missing notes records for following note history ID > note ID", errorList);
await runCheck(`
SELECT
- notes_tree.parentNoteId || ' > ' || notes_tree.noteId
+ note_tree.parentNoteId || ' > ' || note_tree.noteId
FROM
- notes_tree
+ note_tree
WHERE
- notes_tree.isDeleted = 0
+ note_tree.isDeleted = 0
GROUP BY
- notes_tree.parentNoteId,
- notes_tree.noteId
+ note_tree.parentNoteId,
+ note_tree.noteId
HAVING
COUNT(*) > 1`,
"Duplicate undeleted parent note <-> note relationship - parent note ID > note ID", errorList);
@@ -182,19 +182,19 @@ async function runAllChecks() {
images.imageId
FROM
images
- LEFT JOIN notes_image ON notes_image.imageId = images.imageId
+ LEFT JOIN note_images ON note_images.imageId = images.imageId
WHERE
- notes_image.noteImageId IS NULL`,
+ note_images.noteImageId IS NULL`,
"Image with no note relation", errorList);
await runCheck(`
SELECT
- notes_image.noteImageId
+ note_images.noteImageId
FROM
- notes_image
+ note_images
JOIN images USING(imageId)
WHERE
- notes_image.isDeleted = 0
+ note_images.isDeleted = 0
AND images.isDeleted = 1`,
"Note image is not deleted while image is deleted for noteImageId", errorList);
@@ -218,11 +218,11 @@ async function runAllChecks() {
"Note has invalid type", errorList);
await runSyncRowChecks("notes", "noteId", errorList);
- await runSyncRowChecks("notes_history", "noteHistoryId", errorList);
- await runSyncRowChecks("notes_tree", "noteTreeId", errorList);
+ await runSyncRowChecks("note_revisions", "noteRevisionId", errorList);
+ await runSyncRowChecks("note_tree", "noteTreeId", errorList);
await runSyncRowChecks("recent_notes", "noteTreeId", errorList);
await runSyncRowChecks("images", "imageId", errorList);
- await runSyncRowChecks("notes_image", "noteImageId", errorList);
+ await runSyncRowChecks("note_images", "noteImageId", errorList);
if (errorList.length === 0) {
// we run this only if basic checks passed since this assumes basic data consistency
diff --git a/services/content_hash.js b/services/content_hash.js
index 0b5f80199d..b289530705 100644
--- a/services/content_hash.js
+++ b/services/content_hash.js
@@ -29,7 +29,7 @@ async function getHashes() {
FROM notes
ORDER BY noteId`)),
- notes_tree: getHash(await sql.getAll(`
+ note_tree: getHash(await sql.getAll(`
SELECT
noteTreeId,
noteId,
@@ -38,19 +38,19 @@ async function getHashes() {
dateModified,
isDeleted,
prefix
- FROM notes_tree
+ FROM note_tree
ORDER BY noteTreeId`)),
- notes_history: getHash(await sql.getAll(`
+ note_revisions: getHash(await sql.getAll(`
SELECT
- noteHistoryId,
+ noteRevisionId,
noteId,
title,
content,
dateModifiedFrom,
dateModifiedTo
- FROM notes_history
- ORDER BY noteHistoryId`)),
+ FROM note_revisions
+ ORDER BY noteRevisionId`)),
recent_notes: getHash(await sql.getAll(`
SELECT
diff --git a/services/date_notes.js b/services/date_notes.js
index 670da4cf53..487031967a 100644
--- a/services/date_notes.js
+++ b/services/date_notes.js
@@ -19,10 +19,10 @@ async function createNote(parentNoteId, noteTitle, noteText) {
}
async function getNoteStartingWith(parentNoteId, startsWith) {
- return await sql.getFirstValue(`SELECT noteId FROM notes JOIN notes_tree USING(noteId)
+ return await sql.getFirstValue(`SELECT noteId FROM notes JOIN note_tree USING(noteId)
WHERE parentNoteId = ? AND title LIKE '${startsWith}%'
AND notes.isDeleted = 0 AND isProtected = 0
- AND notes_tree.isDeleted = 0`, [parentNoteId]);
+ AND note_tree.isDeleted = 0`, [parentNoteId]);
}
async function getRootNoteId() {
diff --git a/services/notes.js b/services/notes.js
index 768ced1f3a..b2b081734f 100644
--- a/services/notes.js
+++ b/services/notes.js
@@ -53,17 +53,17 @@ async function createNewNote(parentNoteId, noteOpts, dataKey, sourceId) {
let newNotePos = 0;
if (noteOpts.target === 'into') {
- const maxNotePos = await sql.getFirstValue('SELECT MAX(notePosition) FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
+ const maxNotePos = await sql.getFirstValue('SELECT MAX(notePosition) FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
}
else if (noteOpts.target === 'after') {
- const afterNote = await sql.getFirst('SELECT notePosition FROM notes_tree WHERE noteTreeId = ?', [noteOpts.target_noteTreeId]);
+ const afterNote = await sql.getFirst('SELECT notePosition FROM note_tree WHERE noteTreeId = ?', [noteOpts.target_noteTreeId]);
newNotePos = afterNote.notePosition + 1;
// not updating dateModified to avoig having to sync whole rows
- await sql.execute('UPDATE notes_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0',
+ await sql.execute('UPDATE note_tree SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0',
[parentNoteId, afterNote.notePosition]);
await sync_table.addNoteReorderingSync(parentNoteId, sourceId);
@@ -105,7 +105,7 @@ async function createNewNote(parentNoteId, noteOpts, dataKey, sourceId) {
await sync_table.addNoteSync(noteId, sourceId);
- await sql.insert("notes_tree", {
+ await sql.insert("note_tree", {
noteTreeId: noteTreeId,
noteId: noteId,
parentNoteId: parentNoteId,
@@ -129,7 +129,7 @@ async function protectNoteRecursively(noteId, dataKey, protect, sourceId) {
await protectNote(note, dataKey, protect, sourceId);
- const children = await sql.getFirstColumn("SELECT noteId FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0", [noteId]);
+ const children = await sql.getFirstColumn("SELECT noteId FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [noteId]);
for (const childNoteId of children) {
await protectNoteRecursively(childNoteId, dataKey, protect, sourceId);
@@ -165,7 +165,7 @@ async function protectNote(note, dataKey, protect, sourceId) {
}
async function protectNoteHistory(noteId, dataKey, protect, sourceId) {
- const historyToChange = await sql.getAll("SELECT * FROM notes_history WHERE noteId = ? AND isProtected != ?", [noteId, protect]);
+ const historyToChange = await sql.getAll("SELECT * FROM note_revisions WHERE noteId = ? AND isProtected != ?", [noteId, protect]);
for (const history of historyToChange) {
if (protect) {
@@ -179,10 +179,10 @@ async function protectNoteHistory(noteId, dataKey, protect, sourceId) {
history.isProtected = false;
}
- await sql.execute("UPDATE notes_history SET title = ?, content = ?, isProtected = ? WHERE noteHistoryId = ?",
- [history.title, history.content, history.isProtected, history.noteHistoryId]);
+ await sql.execute("UPDATE note_revisions SET title = ?, content = ?, isProtected = ? WHERE noteRevisionId = ?",
+ [history.title, history.content, history.isProtected, history.noteRevisionId]);
- await sync_table.addNoteHistorySync(history.noteHistoryId, sourceId);
+ await sync_table.addNoteHistorySync(history.noteRevisionId, sourceId);
}
}
@@ -195,10 +195,10 @@ async function saveNoteHistory(noteId, dataKey, sourceId, nowStr) {
note.isProtected = false;
}
- const newNoteHistoryId = utils.newNoteHistoryId();
+ const newnoteRevisionId = utils.newnoteRevisionId();
- await sql.insert('notes_history', {
- noteHistoryId: newNoteHistoryId,
+ await sql.insert('note_revisions', {
+ noteRevisionId: newnoteRevisionId,
noteId: noteId,
// title and text should be decrypted now
title: oldNote.title,
@@ -208,11 +208,11 @@ async function saveNoteHistory(noteId, dataKey, sourceId, nowStr) {
dateModifiedTo: nowStr
});
- await sync_table.addNoteHistorySync(newNoteHistoryId, sourceId);
+ await sync_table.addNoteHistorySync(newnoteRevisionId, sourceId);
}
async function saveNoteImages(noteId, noteText, sourceId) {
- const existingNoteImages = await sql.getAll("SELECT * FROM notes_image WHERE noteId = ?", [noteId]);
+ const existingNoteImages = await sql.getAll("SELECT * FROM note_images WHERE noteId = ?", [noteId]);
const foundImageIds = [];
const now = utils.nowDate();
const re = /src="\/api\/images\/([a-zA-Z0-9]+)\//g;
@@ -225,7 +225,7 @@ async function saveNoteImages(noteId, noteText, sourceId) {
if (!existingNoteImage) {
const noteImageId = utils.newNoteImageId();
- await sql.insert("notes_image", {
+ await sql.insert("note_images", {
noteImageId: noteImageId,
noteId: noteId,
imageId: imageId,
@@ -237,7 +237,7 @@ async function saveNoteImages(noteId, noteText, sourceId) {
await sync_table.addNoteImageSync(noteImageId, sourceId);
}
else if (existingNoteImage.isDeleted) {
- await sql.execute("UPDATE notes_image SET isDeleted = 0, dateModified = ? WHERE noteImageId = ?",
+ await sql.execute("UPDATE note_images SET isDeleted = 0, dateModified = ? WHERE noteImageId = ?",
[now, existingNoteImage.noteImageId]);
await sync_table.addNoteImageSync(existingNoteImage.noteImageId, sourceId);
@@ -251,7 +251,7 @@ async function saveNoteImages(noteId, noteText, sourceId) {
const unusedNoteImages = existingNoteImages.filter(ni => !foundImageIds.includes(ni.imageId));
for (const unusedNoteImage of unusedNoteImages) {
- await sql.execute("UPDATE notes_image SET isDeleted = 1, dateModified = ? WHERE noteImageId = ?",
+ await sql.execute("UPDATE note_images SET isDeleted = 1, dateModified = ? WHERE noteImageId = ?",
[now, unusedNoteImage.noteImageId]);
await sync_table.addNoteImageSync(unusedNoteImage.noteImageId, sourceId);
@@ -272,14 +272,14 @@ async function updateNote(noteId, newNote, dataKey, sourceId) {
const historyCutoff = utils.dateStr(new Date(now.getTime() - historySnapshotTimeInterval * 1000));
- const existingNoteHistoryId = await sql.getFirstValue(
- "SELECT noteHistoryId FROM notes_history WHERE noteId = ? AND dateModifiedTo >= ?", [noteId, historyCutoff]);
+ const existingnoteRevisionId = await sql.getFirstValue(
+ "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND dateModifiedTo >= ?", [noteId, historyCutoff]);
await sql.doInTransaction(async () => {
const msSinceDateCreated = now.getTime() - utils.parseDate(newNote.detail.dateCreated).getTime();
if (attributesMap.disable_versioning !== 'true'
- && !existingNoteHistoryId
+ && !existingnoteRevisionId
&& msSinceDateCreated >= historySnapshotTimeInterval * 1000) {
await saveNoteHistory(noteId, dataKey, sourceId, nowStr);
@@ -301,7 +301,7 @@ async function updateNote(noteId, newNote, dataKey, sourceId) {
}
async function deleteNote(noteTreeId, sourceId) {
- const noteTree = await sql.getFirstOrNull("SELECT * FROM notes_tree WHERE noteTreeId = ?", [noteTreeId]);
+ const noteTree = await sql.getFirstOrNull("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]);
if (!noteTree || noteTree.isDeleted === 1) {
return;
@@ -309,18 +309,18 @@ async function deleteNote(noteTreeId, sourceId) {
const now = utils.nowDate();
- await sql.execute("UPDATE notes_tree SET isDeleted = 1, dateModified = ? WHERE noteTreeId = ?", [now, noteTreeId]);
+ await sql.execute("UPDATE note_tree SET isDeleted = 1, dateModified = ? WHERE noteTreeId = ?", [now, noteTreeId]);
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
- const noteId = await sql.getFirstValue("SELECT noteId FROM notes_tree WHERE noteTreeId = ?", [noteTreeId]);
+ const noteId = await sql.getFirstValue("SELECT noteId FROM note_tree WHERE noteTreeId = ?", [noteTreeId]);
- const notDeletedNoteTreesCount = await sql.getFirstValue("SELECT COUNT(*) FROM notes_tree WHERE noteId = ? AND isDeleted = 0", [noteId]);
+ const notDeletedNoteTreesCount = await sql.getFirstValue("SELECT COUNT(*) FROM note_tree WHERE noteId = ? AND isDeleted = 0", [noteId]);
if (!notDeletedNoteTreesCount) {
await sql.execute("UPDATE notes SET isDeleted = 1, dateModified = ? WHERE noteId = ?", [now, noteId]);
await sync_table.addNoteSync(noteId, sourceId);
- const children = await sql.getAll("SELECT noteTreeId FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0", [noteId]);
+ const children = await sql.getAll("SELECT noteTreeId FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [noteId]);
for (const child of children) {
await deleteNote(child.noteTreeId, sourceId);
diff --git a/services/protected_session.js b/services/protected_session.js
index ca3de2aeba..5abe9d4771 100644
--- a/services/protected_session.js
+++ b/services/protected_session.js
@@ -72,11 +72,11 @@ function decryptNoteHistoryRow(dataKey, hist) {
}
if (hist.title) {
- hist.title = data_encryption.decryptString(dataKey, data_encryption.noteTitleIv(hist.noteHistoryId), hist.title);
+ hist.title = data_encryption.decryptString(dataKey, data_encryption.noteTitleIv(hist.noteRevisionId), hist.title);
}
if (hist.content) {
- hist.content = data_encryption.decryptString(dataKey, data_encryption.noteTextIv(hist.noteHistoryId), hist.content);
+ hist.content = data_encryption.decryptString(dataKey, data_encryption.noteTextIv(hist.noteRevisionId), hist.content);
}
}
@@ -98,8 +98,8 @@ function encryptNote(dataKey, note) {
function encryptNoteHistoryRow(dataKey, history) {
dataKey = getDataKey(dataKey);
- history.title = data_encryption.encrypt(dataKey, data_encryption.noteTitleIv(history.noteHistoryId), history.title);
- history.content = data_encryption.encrypt(dataKey, data_encryption.noteTextIv(history.noteHistoryId), history.content);
+ history.title = data_encryption.encrypt(dataKey, data_encryption.noteTitleIv(history.noteRevisionId), history.title);
+ history.content = data_encryption.encrypt(dataKey, data_encryption.noteTextIv(history.noteRevisionId), history.content);
}
module.exports = {
diff --git a/services/sql.js b/services/sql.js
index fdec7fe4c9..16034f5104 100644
--- a/services/sql.js
+++ b/services/sql.js
@@ -30,9 +30,9 @@ const dbReady = new Promise((resolve, reject) => {
const schema = fs.readFileSync(resource_dir.DB_INIT_DIR + '/schema.sql', 'UTF-8');
const notesSql = fs.readFileSync(resource_dir.DB_INIT_DIR + '/main_notes.sql', 'UTF-8');
- const notesTreeSql = fs.readFileSync(resource_dir.DB_INIT_DIR + '/main_notes_tree.sql', 'UTF-8');
+ const notesTreeSql = fs.readFileSync(resource_dir.DB_INIT_DIR + '/main_note_tree.sql', 'UTF-8');
const imagesSql = fs.readFileSync(resource_dir.DB_INIT_DIR + '/main_images.sql', 'UTF-8');
- const notesImageSql = fs.readFileSync(resource_dir.DB_INIT_DIR + '/main_notes_image.sql', 'UTF-8');
+ const notesImageSql = fs.readFileSync(resource_dir.DB_INIT_DIR + '/main_note_images.sql', 'UTF-8');
await doInTransaction(async () => {
await executeScript(schema);
@@ -41,7 +41,7 @@ const dbReady = new Promise((resolve, reject) => {
await executeScript(imagesSql);
await executeScript(notesImageSql);
- const startNoteId = await getFirstValue("SELECT noteId FROM notes_tree WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
+ const startNoteId = await getFirstValue("SELECT noteId FROM note_tree WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
await require('./options').initOptions(startNoteId);
await require('./sync_table').fillAllSyncRows();
diff --git a/services/sync.js b/services/sync.js
index 6fc0266c4c..b585608d50 100644
--- a/services/sync.js
+++ b/services/sync.js
@@ -125,10 +125,10 @@ async function pullSync(syncContext) {
else if (sync.entityName === 'notes') {
await syncUpdate.updateNote(resp.entity, syncContext.sourceId);
}
- else if (sync.entityName === 'notes_tree') {
+ else if (sync.entityName === 'note_tree') {
await syncUpdate.updateNoteTree(resp, syncContext.sourceId);
}
- else if (sync.entityName === 'notes_history') {
+ else if (sync.entityName === 'note_revisions') {
await syncUpdate.updateNoteHistory(resp, syncContext.sourceId);
}
else if (sync.entityName === 'notes_reordering') {
@@ -143,7 +143,7 @@ async function pullSync(syncContext) {
else if (sync.entityName === 'images') {
await syncUpdate.updateImage(resp, syncContext.sourceId);
}
- else if (sync.entityName === 'notes_image') {
+ else if (sync.entityName === 'note_images') {
await syncUpdate.updateNoteImage(resp, syncContext.sourceId);
}
else if (sync.entityName === 'attributes') {
@@ -202,16 +202,16 @@ async function pushEntity(sync, syncContext) {
if (sync.entityName === 'notes') {
entity = await sql.getFirst('SELECT * FROM notes WHERE noteId = ?', [sync.entityId]);
}
- else if (sync.entityName === 'notes_tree') {
- entity = await sql.getFirst('SELECT * FROM notes_tree WHERE noteTreeId = ?', [sync.entityId]);
+ else if (sync.entityName === 'note_tree') {
+ entity = await sql.getFirst('SELECT * FROM note_tree WHERE noteTreeId = ?', [sync.entityId]);
}
- else if (sync.entityName === 'notes_history') {
- entity = await sql.getFirst('SELECT * FROM notes_history WHERE noteHistoryId = ?', [sync.entityId]);
+ else if (sync.entityName === 'note_revisions') {
+ entity = await sql.getFirst('SELECT * FROM note_revisions WHERE noteRevisionId = ?', [sync.entityId]);
}
else if (sync.entityName === 'notes_reordering') {
entity = {
parentNoteId: sync.entityId,
- ordering: await sql.getMap('SELECT noteTreeId, notePosition FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0', [sync.entityId])
+ ordering: await sql.getMap('SELECT noteTreeId, notePosition FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0', [sync.entityId])
};
}
else if (sync.entityName === 'options') {
@@ -227,8 +227,8 @@ async function pushEntity(sync, syncContext) {
entity.data = entity.data.toString('base64');
}
}
- else if (sync.entityName === 'notes_image') {
- entity = await sql.getFirst('SELECT * FROM notes_image WHERE noteImageId = ?', [sync.entityId]);
+ else if (sync.entityName === 'note_images') {
+ entity = await sql.getFirst('SELECT * FROM note_images WHERE noteImageId = ?', [sync.entityId]);
}
else if (sync.entityName === 'attributes') {
entity = await sql.getFirst('SELECT * FROM attributes WHERE attributeId = ?', [sync.entityId]);
diff --git a/services/sync_table.js b/services/sync_table.js
index 81e2862f57..8cf4aec3f0 100644
--- a/services/sync_table.js
+++ b/services/sync_table.js
@@ -9,15 +9,15 @@ async function addNoteSync(noteId, sourceId) {
}
async function addNoteTreeSync(noteTreeId, sourceId) {
- await addEntitySync("notes_tree", noteTreeId, sourceId)
+ await addEntitySync("note_tree", noteTreeId, sourceId)
}
async function addNoteReorderingSync(parentNoteTreeId, sourceId) {
await addEntitySync("notes_reordering", parentNoteTreeId, sourceId)
}
-async function addNoteHistorySync(noteHistoryId, sourceId) {
- await addEntitySync("notes_history", noteHistoryId, sourceId);
+async function addNoteHistorySync(noteRevisionId, sourceId) {
+ await addEntitySync("note_revisions", noteRevisionId, sourceId);
}
async function addOptionsSync(name, sourceId) {
@@ -33,7 +33,7 @@ async function addImageSync(imageId, sourceId) {
}
async function addNoteImageSync(noteImageId, sourceId) {
- await addEntitySync("notes_image", noteImageId, sourceId);
+ await addEntitySync("note_images", noteImageId, sourceId);
}
async function addAttributeSync(attributeId, sourceId) {
@@ -87,11 +87,11 @@ async function fillSyncRows(entityName, entityKey) {
async function fillAllSyncRows() {
await fillSyncRows("notes", "noteId");
- await fillSyncRows("notes_tree", "noteTreeId");
- await fillSyncRows("notes_history", "noteHistoryId");
+ await fillSyncRows("note_tree", "noteTreeId");
+ await fillSyncRows("note_revisions", "noteRevisionId");
await fillSyncRows("recent_notes", "noteTreeId");
await fillSyncRows("images", "imageId");
- await fillSyncRows("notes_image", "noteImageId");
+ await fillSyncRows("note_images", "noteImageId");
await fillSyncRows("attributes", "attributeId");
}
diff --git a/services/sync_update.js b/services/sync_update.js
index 6f11d9d29c..03ea38633f 100644
--- a/services/sync_update.js
+++ b/services/sync_update.js
@@ -20,13 +20,13 @@ async function updateNote(entity, sourceId) {
}
async function updateNoteTree(entity, sourceId) {
- const orig = await sql.getFirstOrNull("SELECT * FROM notes_tree WHERE noteTreeId = ?", [entity.noteTreeId]);
+ const orig = await sql.getFirstOrNull("SELECT * FROM note_tree WHERE noteTreeId = ?", [entity.noteTreeId]);
await sql.doInTransaction(async () => {
if (orig === null || orig.dateModified < entity.dateModified) {
delete entity.isExpanded;
- await sql.replace('notes_tree', entity);
+ await sql.replace('note_tree', entity);
await sync_table.addNoteTreeSync(entity.noteTreeId, sourceId);
@@ -36,17 +36,17 @@ async function updateNoteTree(entity, sourceId) {
}
async function updateNoteHistory(entity, sourceId) {
- const orig = await sql.getFirstOrNull("SELECT * FROM notes_history WHERE noteHistoryId = ?", [entity.noteHistoryId]);
+ const orig = await sql.getFirstOrNull("SELECT * FROM note_revisions WHERE noteRevisionId = ?", [entity.noteRevisionId]);
await sql.doInTransaction(async () => {
// we update note history even if date modified to is the same because the only thing which might have changed
// is the protected status (and correnspondingly title and content) which doesn't affect the dateModifiedTo
if (orig === null || orig.dateModifiedTo <= entity.dateModifiedTo) {
- await sql.replace('notes_history', entity);
+ await sql.replace('note_revisions', entity);
- await sync_table.addNoteHistorySync(entity.noteHistoryId, sourceId);
+ await sync_table.addNoteHistorySync(entity.noteRevisionId, sourceId);
- log.info("Update/sync note history " + entity.noteHistoryId);
+ log.info("Update/sync note history " + entity.noteRevisionId);
}
});
}
@@ -54,7 +54,7 @@ async function updateNoteHistory(entity, sourceId) {
async function updateNoteReordering(entity, sourceId) {
await sql.doInTransaction(async () => {
Object.keys(entity.ordering).forEach(async key => {
- await sql.execute("UPDATE notes_tree SET notePosition = ? WHERE noteTreeId = ?", [entity.ordering[key], key]);
+ await sql.execute("UPDATE note_tree SET notePosition = ? WHERE noteTreeId = ?", [entity.ordering[key], key]);
});
await sync_table.addNoteReorderingSync(entity.parentNoteId, sourceId);
@@ -110,11 +110,11 @@ async function updateImage(entity, sourceId) {
}
async function updateNoteImage(entity, sourceId) {
- const origNoteImage = await sql.getFirst("SELECT * FROM notes_image WHERE noteImageId = ?", [entity.noteImageId]);
+ const origNoteImage = await sql.getFirst("SELECT * FROM note_images WHERE noteImageId = ?", [entity.noteImageId]);
if (!origNoteImage || origNoteImage.dateModified <= entity.dateModified) {
await sql.doInTransaction(async () => {
- await sql.replace("notes_image", entity);
+ await sql.replace("note_images", entity);
await sync_table.addNoteImageSync(entity.noteImageId, sourceId);
});
diff --git a/services/tree.js b/services/tree.js
index 46b4fa9744..60531b4bbf 100644
--- a/services/tree.js
+++ b/services/tree.js
@@ -28,7 +28,7 @@ async function validateParentChild(res, parentNoteId, childNoteId, noteTreeId =
}
async function getExistingNoteTree(parentNoteId, childNoteId) {
- return await sql.getFirst('SELECT * FROM notes_tree WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
+ return await sql.getFirst('SELECT * FROM note_tree WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
}
/**
@@ -51,7 +51,7 @@ async function checkTreeCycle(parentNoteId, childNoteId) {
return false;
}
- const parentNoteIds = await sql.getFirstColumn("SELECT DISTINCT parentNoteId FROM notes_tree WHERE noteId = ? AND isDeleted = 0", [parentNoteId]);
+ const parentNoteIds = await sql.getFirstColumn("SELECT DISTINCT parentNoteId FROM note_tree WHERE noteId = ? AND isDeleted = 0", [parentNoteId]);
for (const pid of parentNoteIds) {
if (!await checkTreeCycleInner(pid)) {
@@ -66,13 +66,13 @@ async function checkTreeCycle(parentNoteId, childNoteId) {
}
async function getNoteTree(noteTreeId) {
- return sql.getFirst("SELECT * FROM notes_tree WHERE noteTreeId = ?", [noteTreeId]);
+ return sql.getFirst("SELECT * FROM note_tree WHERE noteTreeId = ?", [noteTreeId]);
}
async function loadSubTreeNoteIds(parentNoteId, subTreeNoteIds) {
subTreeNoteIds.push(parentNoteId);
- const children = await sql.getFirstColumn("SELECT noteId FROM notes_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]);
+ const children = await sql.getFirstColumn("SELECT noteId FROM note_tree WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]);
for (const childNoteId of children) {
await loadSubTreeNoteIds(childNoteId, subTreeNoteIds);
@@ -82,8 +82,8 @@ async function loadSubTreeNoteIds(parentNoteId, subTreeNoteIds) {
async function sortNotesAlphabetically(parentNoteId, req, sourceId) {
await sql.doInTransaction(async () => {
const notes = await sql.getAll(`SELECT noteTreeId, noteId, title, isProtected
- FROM notes JOIN notes_tree USING(noteId)
- WHERE notes_tree.isDeleted = 0 AND parentNoteId = ?`, [parentNoteId]);
+ FROM notes JOIN note_tree USING(noteId)
+ WHERE note_tree.isDeleted = 0 AND parentNoteId = ?`, [parentNoteId]);
protected_session.decryptNotes(req, notes);
@@ -92,7 +92,7 @@ async function sortNotesAlphabetically(parentNoteId, req, sourceId) {
let position = 1;
for (const note of notes) {
- await sql.execute("UPDATE notes_tree SET notePosition = ? WHERE noteTreeId = ?",
+ await sql.execute("UPDATE note_tree SET notePosition = ? WHERE noteTreeId = ?",
[position, note.noteTreeId]);
position++;
diff --git a/services/utils.js b/services/utils.js
index 9dd608b7db..190dcd2c05 100644
--- a/services/utils.js
+++ b/services/utils.js
@@ -11,7 +11,7 @@ function newNoteTreeId() {
return randomString(12);
}
-function newNoteHistoryId() {
+function newnoteRevisionId() {
return randomString(12);
}
@@ -119,7 +119,7 @@ module.exports = {
parseDate,
newNoteId,
newNoteTreeId,
- newNoteHistoryId,
+ newnoteRevisionId,
newImageId,
newNoteImageId,
newAttributeId,