From fd00f6bd9739daf845a861a09743ff484cb568b2 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 23 Sep 2021 22:09:11 +0200 Subject: [PATCH] removed older migrations since they don't work anyway (after becca refactoring) --- .../0113__left_pane_size_options.sql | 5 - db/migrations/0114__fix_root_note_cycle.sql | 1 - db/migrations/0115__images_in_notes.sql | 75 ------ db/migrations/0116__add_indexes.sql | 14 -- .../0117__fix_attributes_of_deleted_notes.sql | 1 - db/migrations/0118__fix_broken_relations.sql | 1 - .../0119__rename_mirror_to_inverse.sql | 1 - ...migrate_hideInAutocomplete_to_archived.sql | 1 - db/migrations/0121__add_hoisting_option.sql | 2 - db/migrations/0122__add_iv_to_columns.js | 62 ----- .../0123__add_options_for_font_sizes.sql | 8 - db/migrations/0124__readd_font_sizes.sql | 11 - .../0125__create_note_content_table.sql | 35 --- .../0126__fill_sync_for_note_contents.sql | 2 - .../0127__fix_inconsistent_isProtected.sql | 6 - db/migrations/0128__add_note_fulltext.sql | 0 db/migrations/0129__fill_note_fulltext.js | 1 - db/migrations/0130__rename_dates_to_utc.sql | 236 ------------------ db/migrations/0131__cleanup_note_contents.sql | 13 - db/migrations/0132__fill_sync.js | 5 - db/migrations/0133__drop_note_fulltext.sql | 1 - .../0134__create_openTabs_option.sql | 4 - .../0135__add_hideTabRowForOneTab_option.sql | 2 - db/migrations/0136__update_recent_notes.sql | 12 - db/migrations/0137__links_to_attributes.sql | 10 - db/migrations/0138__sidebar_sizing.sql | 5 - .../0139__show_sidebar_in_new_tab.sql | 2 - db/migrations/0140__widget_config.sql | 14 -- .../0141__add_code_note_mime_types.sql | 5 - db/migrations/0142__similar_notes_widget.sql | 2 - db/migrations/0143__drop_event_log.sql | 1 - db/migrations/0144__edited_notes_widget.sql | 2 - db/migrations/0145__calendar_widget.sql | 2 - .../0146__add_spell_check_options.sql | 5 - ...47__add_hideTabRowForOneTab_if_missing.sql | 3 - .../0148__make_isExpanded_not_null.sql | 22 -- db/migrations/0149__space_out_positions.sql | 2 - .../0150__note_revision_contents.sql | 36 --- db/migrations/0151__add_isErased_to_note.sql | 31 --- .../0152__add_contentLength_to_note.sql | 34 --- .../0153__add_isErased_to_note_revision.sql | 28 --- ...__system_links_should_follow_camelCase.sql | 3 - db/migrations/0155__indexes.sql | 5 - db/migrations/0156__add_deleteId.sql | 81 ------ db/migrations/0157__fix_contentLength.sql | 1 - db/migrations/0158__add_isSynced_to_sync.sql | 22 -- .../0159__fix_isSynced_in_sync_rows.sql | 4 - .../0160__migrate_attr_definitions.sql | 2 - db/migrations/0161__attr_def_short.js | 79 ------ db/migrations/0162__drop_source_ids.sql | 1 - .../0163__rename_sync_to_entity_changes.sql | 1 - db/migrations/0164__rename_utcSyncDate.sql | 22 -- db/migrations/0165__move_contentLength.sql | 55 ---- ...0166__add_dateModified_to_note_content.sql | 20 -- .../0167__remove_activateParentNote.sql | 1 - ..._rename_hideInAutocomplete_to_archived.sql | 1 - db/migrations/0169__convert_h1_to_h2.js | 20 -- db/migrations/0170__fix_branch_ordering.js | 14 -- db/migrations/0171__cleanup_options.sql | 15 -- .../0173__isErased_in_entity_changes.sql | 69 ----- .../0174__move_hash_to_entity_changes.sql | 198 --------------- ...5__rename_eraseNotesAfterTimeInSeconds.sql | 2 - ...6__remove_utcDateCreated_in_attributes.sql | 25 -- .../0177__cleanup_keyboard_shortcuts.sql | 5 - db/migrations/0178__drop_isDeleted_index.sql | 1 - db/migrations/0179__VACUUM.sql | 1 - .../0180__rename_quickSearch_shortcut.sql | 2 - .../0181__fix_entityChanges_isSynced.sql | 5 - ...emove_recentChanges_from_entityChanges.sql | 14 -- .../0183__migrate_saved_search_notes.js | 25 -- 70 files changed, 1397 deletions(-) delete mode 100644 db/migrations/0113__left_pane_size_options.sql delete mode 100644 db/migrations/0114__fix_root_note_cycle.sql delete mode 100644 db/migrations/0115__images_in_notes.sql delete mode 100644 db/migrations/0116__add_indexes.sql delete mode 100644 db/migrations/0117__fix_attributes_of_deleted_notes.sql delete mode 100644 db/migrations/0118__fix_broken_relations.sql delete mode 100644 db/migrations/0119__rename_mirror_to_inverse.sql delete mode 100644 db/migrations/0120__migrate_hideInAutocomplete_to_archived.sql delete mode 100644 db/migrations/0121__add_hoisting_option.sql delete mode 100644 db/migrations/0122__add_iv_to_columns.js delete mode 100644 db/migrations/0123__add_options_for_font_sizes.sql delete mode 100644 db/migrations/0124__readd_font_sizes.sql delete mode 100644 db/migrations/0125__create_note_content_table.sql delete mode 100644 db/migrations/0126__fill_sync_for_note_contents.sql delete mode 100644 db/migrations/0127__fix_inconsistent_isProtected.sql delete mode 100644 db/migrations/0128__add_note_fulltext.sql delete mode 100644 db/migrations/0129__fill_note_fulltext.js delete mode 100644 db/migrations/0130__rename_dates_to_utc.sql delete mode 100644 db/migrations/0131__cleanup_note_contents.sql delete mode 100644 db/migrations/0132__fill_sync.js delete mode 100644 db/migrations/0133__drop_note_fulltext.sql delete mode 100644 db/migrations/0134__create_openTabs_option.sql delete mode 100644 db/migrations/0135__add_hideTabRowForOneTab_option.sql delete mode 100644 db/migrations/0136__update_recent_notes.sql delete mode 100644 db/migrations/0137__links_to_attributes.sql delete mode 100644 db/migrations/0138__sidebar_sizing.sql delete mode 100644 db/migrations/0139__show_sidebar_in_new_tab.sql delete mode 100644 db/migrations/0140__widget_config.sql delete mode 100644 db/migrations/0141__add_code_note_mime_types.sql delete mode 100644 db/migrations/0142__similar_notes_widget.sql delete mode 100644 db/migrations/0143__drop_event_log.sql delete mode 100644 db/migrations/0144__edited_notes_widget.sql delete mode 100644 db/migrations/0145__calendar_widget.sql delete mode 100644 db/migrations/0146__add_spell_check_options.sql delete mode 100644 db/migrations/0147__add_hideTabRowForOneTab_if_missing.sql delete mode 100644 db/migrations/0148__make_isExpanded_not_null.sql delete mode 100644 db/migrations/0149__space_out_positions.sql delete mode 100644 db/migrations/0150__note_revision_contents.sql delete mode 100644 db/migrations/0151__add_isErased_to_note.sql delete mode 100644 db/migrations/0152__add_contentLength_to_note.sql delete mode 100644 db/migrations/0153__add_isErased_to_note_revision.sql delete mode 100644 db/migrations/0154__system_links_should_follow_camelCase.sql delete mode 100644 db/migrations/0155__indexes.sql delete mode 100644 db/migrations/0156__add_deleteId.sql delete mode 100644 db/migrations/0157__fix_contentLength.sql delete mode 100644 db/migrations/0158__add_isSynced_to_sync.sql delete mode 100644 db/migrations/0159__fix_isSynced_in_sync_rows.sql delete mode 100644 db/migrations/0160__migrate_attr_definitions.sql delete mode 100644 db/migrations/0161__attr_def_short.js delete mode 100644 db/migrations/0162__drop_source_ids.sql delete mode 100644 db/migrations/0163__rename_sync_to_entity_changes.sql delete mode 100644 db/migrations/0164__rename_utcSyncDate.sql delete mode 100644 db/migrations/0165__move_contentLength.sql delete mode 100644 db/migrations/0166__add_dateModified_to_note_content.sql delete mode 100644 db/migrations/0167__remove_activateParentNote.sql delete mode 100644 db/migrations/0168__rename_hideInAutocomplete_to_archived.sql delete mode 100644 db/migrations/0169__convert_h1_to_h2.js delete mode 100644 db/migrations/0170__fix_branch_ordering.js delete mode 100644 db/migrations/0171__cleanup_options.sql delete mode 100644 db/migrations/0173__isErased_in_entity_changes.sql delete mode 100644 db/migrations/0174__move_hash_to_entity_changes.sql delete mode 100644 db/migrations/0175__rename_eraseNotesAfterTimeInSeconds.sql delete mode 100644 db/migrations/0176__remove_utcDateCreated_in_attributes.sql delete mode 100644 db/migrations/0177__cleanup_keyboard_shortcuts.sql delete mode 100644 db/migrations/0178__drop_isDeleted_index.sql delete mode 100644 db/migrations/0179__VACUUM.sql delete mode 100644 db/migrations/0180__rename_quickSearch_shortcut.sql delete mode 100644 db/migrations/0181__fix_entityChanges_isSynced.sql delete mode 100644 db/migrations/0182__remove_recentChanges_from_entityChanges.sql delete mode 100644 db/migrations/0183__migrate_saved_search_notes.js diff --git a/db/migrations/0113__left_pane_size_options.sql b/db/migrations/0113__left_pane_size_options.sql deleted file mode 100644 index 42417ef8d..000000000 --- a/db/migrations/0113__left_pane_size_options.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) -VALUES ('leftPaneMinWidth', '350', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); - -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) -VALUES ('leftPaneWidthPercent', '20', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0114__fix_root_note_cycle.sql b/db/migrations/0114__fix_root_note_cycle.sql deleted file mode 100644 index bd65c1b9c..000000000 --- a/db/migrations/0114__fix_root_note_cycle.sql +++ /dev/null @@ -1 +0,0 @@ -update branches set parentNoteId = 'none' where branchId = 'root' \ No newline at end of file diff --git a/db/migrations/0115__images_in_notes.sql b/db/migrations/0115__images_in_notes.sql deleted file mode 100644 index bf1695d3b..000000000 --- a/db/migrations/0115__images_in_notes.sql +++ /dev/null @@ -1,75 +0,0 @@ --- first fix deleted status of existing images -UPDATE note_images SET isDeleted = 1 WHERE noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1); - --- we don't need set data to null because table is going to be dropped anyway and we want image size into attribute -UPDATE images SET isDeleted = 1 WHERE imageId NOT IN (SELECT imageId FROM note_images WHERE isDeleted = 0); - --- allow null for note content (for deleted notes) -CREATE TABLE IF NOT EXISTS "notes_mig" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `content` TEXT NULL DEFAULT NULL, - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INT NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`) -); - -INSERT INTO notes_mig (noteId, title, content, isProtected, isDeleted, dateCreated, dateModified, type, mime, hash) -SELECT noteId, title, content, isProtected, isDeleted, dateCreated, dateModified, type, mime, hash FROM notes; - -DROP TABLE notes; - -ALTER TABLE notes_mig RENAME TO notes; - -CREATE TABLE "links" ( - `linkId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `targetNoteId` TEXT NOT NULL, - `type` TEXT NOT NULL, - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INTEGER NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - PRIMARY KEY(`linkId`) -); - -INSERT INTO links (linkId, noteId, targetNoteId, type, isDeleted, dateCreated, dateModified) - SELECT 'L' || SUBSTR(noteImageId, 2), noteId, imageId, 'image', isDeleted, dateCreated, dateModified FROM note_images; - -INSERT INTO branches (branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified, hash, dateCreated) - SELECT 'B' || SUBSTR(noteImageId, 2), imageId, noteId, 100, '', 0, isDeleted, dateModified, hash, dateCreated FROM note_images; - -DROP TABLE note_images; - -INSERT INTO notes (noteId, title, content, isProtected, isDeleted, dateCreated, dateModified, type, mime, hash) - SELECT imageId, name, data, 0, isDeleted, dateCreated, dateModified, 'image', 'image/' || format, hash FROM images; - -INSERT INTO attributes (attributeId, noteId, type, name, value, position, dateCreated, dateModified, isDeleted, hash, isInheritable) - SELECT 'O' || SUBSTR(imageId, 2), imageId, 'label', 'originalFileName', name, 0, dateCreated, dateModified, isDeleted, '', 0 FROM images; - -INSERT INTO attributes (attributeId, noteId, type, name, value, position, dateCreated, dateModified, isDeleted, hash, isInheritable) -SELECT 'F' || SUBSTR(imageId, 2), imageId, 'label', 'fileSize', LENGTH(data), 0, dateCreated, dateModified, isDeleted, '', 0 FROM images; - -DROP TABLE images; - -INSERT INTO sync (entityName, entityId, sourceId, syncDate) -SELECT 'attributes', 'O' || SUBSTR(entityId, 2), sourceId, syncDate FROM sync WHERE entityName = 'images'; - -INSERT INTO sync (entityName, entityId, sourceId, syncDate) -SELECT 'attributes', 'F' || SUBSTR(entityId, 2), sourceId, syncDate FROM sync WHERE entityName = 'images'; - -UPDATE sync SET entityName = 'notes' WHERE entityName = 'images'; - -INSERT INTO sync (entityName, entityId, sourceId, syncDate) -SELECT 'links', 'L' || SUBSTR(entityId, 2), sourceId, syncDate FROM sync WHERE entityName = 'note_images'; - -INSERT INTO sync (entityName, entityId, sourceId, syncDate) - SELECT 'branches', 'B' || SUBSTR(entityId, 2), sourceId, syncDate FROM sync WHERE entityName = 'note_images'; - -DELETE FROM sync WHERE entityName = 'note_images'; -DELETE FROM sync WHERE entityName = 'images'; \ No newline at end of file diff --git a/db/migrations/0116__add_indexes.sql b/db/migrations/0116__add_indexes.sql deleted file mode 100644 index 32bec3247..000000000 --- a/db/migrations/0116__add_indexes.sql +++ /dev/null @@ -1,14 +0,0 @@ -create index IDX_links_noteId_index - on links (noteId); - -create index IDX_links_targetNoteId_index - on links (targetNoteId); - -create index IDX_attributes_name_index - on attributes (name); - -create index IDX_attributes_noteId_index - on attributes (noteId); - -create index IDX_attributes_value_index - on attributes (value); diff --git a/db/migrations/0117__fix_attributes_of_deleted_notes.sql b/db/migrations/0117__fix_attributes_of_deleted_notes.sql deleted file mode 100644 index a078f711f..000000000 --- a/db/migrations/0117__fix_attributes_of_deleted_notes.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE attributes SET isDeleted = 1 WHERE noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1); \ No newline at end of file diff --git a/db/migrations/0118__fix_broken_relations.sql b/db/migrations/0118__fix_broken_relations.sql deleted file mode 100644 index 797d4ae90..000000000 --- a/db/migrations/0118__fix_broken_relations.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE attributes SET isDeleted = 1 WHERE type = 'relation' AND value NOT IN (SELECT noteId FROM notes WHERE notes.isDeleted = 0); \ No newline at end of file diff --git a/db/migrations/0119__rename_mirror_to_inverse.sql b/db/migrations/0119__rename_mirror_to_inverse.sql deleted file mode 100644 index 203b18959..000000000 --- a/db/migrations/0119__rename_mirror_to_inverse.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE attributes SET value = replace(value, 'mirrorRelation', 'inverseRelation') WHERE type = 'relation-definition'; \ No newline at end of file diff --git a/db/migrations/0120__migrate_hideInAutocomplete_to_archived.sql b/db/migrations/0120__migrate_hideInAutocomplete_to_archived.sql deleted file mode 100644 index f47c89b2a..000000000 --- a/db/migrations/0120__migrate_hideInAutocomplete_to_archived.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE attributes SET name = 'archived' where name = 'hideInAutocomplete'; \ No newline at end of file diff --git a/db/migrations/0121__add_hoisting_option.sql b/db/migrations/0121__add_hoisting_option.sql deleted file mode 100644 index 1b0458592..000000000 --- a/db/migrations/0121__add_hoisting_option.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) -VALUES ('hoistedNoteId', 'root', '2018-12-11T18:31:00.874Z', '2018-12-11T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0122__add_iv_to_columns.js b/db/migrations/0122__add_iv_to_columns.js deleted file mode 100644 index b20cd53f8..000000000 --- a/db/migrations/0122__add_iv_to_columns.js +++ /dev/null @@ -1,62 +0,0 @@ -const sql = require('../../src/services/sql'); - -function prependIv(cipherText, ivText) { - const arr = ivText.split("").map(c => parseInt(c) || 0); - const iv = Buffer.from(arr); - const payload = Buffer.from(cipherText, 'base64'); - const complete = Buffer.concat([iv, payload]); - - return complete.toString('base64'); -} - -async function updateEncryptedDataKey() { - const encryptedDataKey = await sql.getValue("SELECT value FROM options WHERE name = 'encryptedDataKey'"); - const encryptedDataKeyIv = await sql.getValue("SELECT value FROM options WHERE name = 'encryptedDataKeyIv'"); - - const newEncryptedDataKey = prependIv(encryptedDataKey, encryptedDataKeyIv); - - await sql.execute("UPDATE options SET value = ? WHERE name = 'encryptedDataKey'", [newEncryptedDataKey]); - - await sql.execute("DELETE FROM options WHERE name = 'encryptedDataKeyIv'"); - await sql.execute("DELETE FROM sync WHERE entityName = 'options' AND entityId = 'encryptedDataKeyIv'"); -} - -async function updateNotes() { - const protectedNotes = await sql.getRows("SELECT noteId, title, content FROM notes WHERE isProtected = 1"); - - for (const note of protectedNotes) { - if (note.title !== null) { - note.title = prependIv(note.title, "0" + note.noteId); - } - - if (note.content !== null) { - note.content = prependIv(note.content, "1" + note.noteId); - } - - await sql.execute("UPDATE notes SET title = ?, content = ? WHERE noteId = ?", [note.title, note.content, note.noteId]); - } -} - -async function updateNoteRevisions() { - const protectedNoteRevisions = await sql.getRows("SELECT noteRevisionId, title, content FROM note_revisions WHERE isProtected = 1"); - - for (const noteRevision of protectedNoteRevisions) { - if (noteRevision.title !== null) { - noteRevision.title = prependIv(noteRevision.title, "0" + noteRevision.noteRevisionId); - } - - if (noteRevision.content !== null) { - noteRevision.content = prependIv(noteRevision.content, "1" + noteRevision.noteRevisionId); - } - - await sql.execute("UPDATE note_revisions SET title = ?, content = ? WHERE noteRevisionId = ?", [noteRevision.title, noteRevision.content, noteRevision.noteRevisionId]); - } -} - -module.exports = async () => { - await updateEncryptedDataKey(); - - await updateNotes(); - - await updateNoteRevisions(); -}; \ No newline at end of file diff --git a/db/migrations/0123__add_options_for_font_sizes.sql b/db/migrations/0123__add_options_for_font_sizes.sql deleted file mode 100644 index d855d7692..000000000 --- a/db/migrations/0123__add_options_for_font_sizes.sql +++ /dev/null @@ -1,8 +0,0 @@ -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) -VALUES ('mainFontSize', '100', '2019-01-13T18:31:00.874Z', '2019-01-13T18:31:00.874Z', 0); - -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) -VALUES ('treeFontSize', '100', '2019-01-13T18:31:00.874Z', '2019-01-13T18:31:00.874Z', 0); - -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) -VALUES ('detailFontSize', '110', '2019-01-13T18:31:00.874Z', '2019-01-13T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0124__readd_font_sizes.sql b/db/migrations/0124__readd_font_sizes.sql deleted file mode 100644 index 6753b6b7c..000000000 --- a/db/migrations/0124__readd_font_sizes.sql +++ /dev/null @@ -1,11 +0,0 @@ -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) - SELECT 'mainFontSize', '100', '2019-01-13T18:31:00.874Z', '2019-01-13T18:31:00.874Z', 0 - WHERE NOT EXISTS (SELECT 1 FROM options WHERE name = 'mainFontSize'); - -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) - SELECT 'treeFontSize', '100', '2019-01-13T18:31:00.874Z', '2019-01-13T18:31:00.874Z', 0 - WHERE NOT EXISTS (SELECT 1 FROM options WHERE name = 'treeFontSize'); - -INSERT INTO options (name, value, dateCreated, dateModified, isSynced) - SELECT 'detailFontSize', '110', '2019-01-13T18:31:00.874Z', '2019-01-13T18:31:00.874Z', 0 - WHERE NOT EXISTS (SELECT 1 FROM options WHERE name = 'detailFontSize'); \ No newline at end of file diff --git a/db/migrations/0125__create_note_content_table.sql b/db/migrations/0125__create_note_content_table.sql deleted file mode 100644 index 788b27722..000000000 --- a/db/migrations/0125__create_note_content_table.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE IF NOT EXISTS "note_contents" ( - `noteContentId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `isProtected` INT NOT NULL DEFAULT 0, - `content` TEXT NULL DEFAULT NULL, - `hash` TEXT DEFAULT "" NOT NULL, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - PRIMARY KEY(`noteContentId`) -); - -CREATE UNIQUE INDEX `IDX_note_contents_noteId` ON `note_contents` (`noteId`); - -INSERT INTO note_contents (noteContentId, noteId, isProtected, content, dateCreated, dateModified) - SELECT 'C' || SUBSTR(noteId, 2), noteId, isProtected, content, dateCreated, dateModified FROM notes; - -CREATE TABLE IF NOT EXISTS "notes_mig" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INT NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`) -); - -INSERT INTO notes_mig (noteId, title, isProtected, isDeleted, dateCreated, dateModified, type, mime, hash) -SELECT noteId, title, isProtected, isDeleted, dateCreated, dateModified, type, mime, hash FROM notes; - -DROP TABLE notes; - -ALTER TABLE notes_mig RENAME TO notes; diff --git a/db/migrations/0126__fill_sync_for_note_contents.sql b/db/migrations/0126__fill_sync_for_note_contents.sql deleted file mode 100644 index 3984919da..000000000 --- a/db/migrations/0126__fill_sync_for_note_contents.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT OR REPLACE INTO sync (entityName, entityId, sourceId, syncDate) -SELECT 'note_contents', noteContentId, '', '2019-03-02T18:07:29.182Z' FROM note_contents; \ No newline at end of file diff --git a/db/migrations/0127__fix_inconsistent_isProtected.sql b/db/migrations/0127__fix_inconsistent_isProtected.sql deleted file mode 100644 index 6b4467e44..000000000 --- a/db/migrations/0127__fix_inconsistent_isProtected.sql +++ /dev/null @@ -1,6 +0,0 @@ -UPDATE notes SET title = 'Recovered protected note', isProtected = 0 WHERE noteId IN ( - SELECT noteId FROM notes JOIN note_contents USING(noteId) - WHERE notes.isProtected = 1 - AND note_contents.isProtected = 0 - AND notes.isDeleted = 0 -) \ No newline at end of file diff --git a/db/migrations/0128__add_note_fulltext.sql b/db/migrations/0128__add_note_fulltext.sql deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/migrations/0129__fill_note_fulltext.js b/db/migrations/0129__fill_note_fulltext.js deleted file mode 100644 index 3bd8337a0..000000000 --- a/db/migrations/0129__fill_note_fulltext.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = async () => {}; \ No newline at end of file diff --git a/db/migrations/0130__rename_dates_to_utc.sql b/db/migrations/0130__rename_dates_to_utc.sql deleted file mode 100644 index 05dca0df5..000000000 --- a/db/migrations/0130__rename_dates_to_utc.sql +++ /dev/null @@ -1,236 +0,0 @@ -CREATE TABLE IF NOT EXISTS "sync_mig" ( - `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `entityName` TEXT NOT NULL, - `entityId` TEXT NOT NULL, - `sourceId` TEXT NOT NULL, - `utcSyncDate` TEXT NOT NULL); - -INSERT INTO sync_mig (id, entityName, entityId, sourceId, utcSyncDate) - SELECT id, entityName, entityId, sourceId, REPLACE(syncDate, 'T', ' ') FROM sync; - -DROP TABLE sync; -ALTER TABLE sync_mig RENAME TO sync; - - -CREATE TABLE IF NOT EXISTS "source_ids_mig" ( - `sourceId` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - PRIMARY KEY(`sourceId`) -); - -INSERT INTO source_ids_mig (sourceId, utcDateCreated) - SELECT sourceId, REPLACE(dateCreated, 'T', ' ') FROM source_ids; - -DROP TABLE source_ids; -ALTER TABLE source_ids_mig RENAME TO source_ids; - -CREATE TABLE IF NOT EXISTS "note_revisions_mig" ( - `noteRevisionId` TEXT NOT NULL PRIMARY KEY, - `noteId` TEXT NOT NULL, - `title` TEXT, - `content` TEXT, - `isProtected` INT NOT NULL DEFAULT 0, - `utcDateModifiedFrom` TEXT NOT NULL, - `utcDateModifiedTo` TEXT NOT NULL, - `dateModifiedFrom` TEXT NOT NULL, - `dateModifiedTo` TEXT NOT NULL, - type TEXT DEFAULT '' NOT NULL, - mime TEXT DEFAULT '' NOT NULL, - hash TEXT DEFAULT "" NOT NULL); - -INSERT INTO note_revisions_mig (noteRevisionId, noteId, title, content, isProtected, utcDateModifiedFrom, utcDateModifiedTo, dateModifiedFrom, dateModifiedTo, type, mime, hash) -SELECT noteRevisionId, noteId, title, content, isProtected, REPLACE(dateModifiedFrom, 'T', ' '), REPLACE(dateModifiedTo, 'T', ' '), REPLACE(REPLACE(dateModifiedFrom, 'T', ' '), 'Z', '+0000'), REPLACE(REPLACE(dateModifiedTo, 'T', ' '), 'Z', '+0000'), type, mime, hash FROM note_revisions; - -DROP TABLE note_revisions; -ALTER TABLE note_revisions_mig RENAME TO note_revisions; - -CREATE TABLE IF NOT EXISTS "api_tokens_mig" -( - apiTokenId TEXT PRIMARY KEY NOT NULL, - token TEXT NOT NULL, - utcDateCreated TEXT NOT NULL, - isDeleted INT NOT NULL DEFAULT 0, - hash TEXT DEFAULT "" NOT NULL); - -INSERT INTO api_tokens_mig (apiTokenId, token, utcDateCreated, isDeleted, hash) - SELECT apiTokenId, token, REPLACE(dateCreated, 'T', ' '), isDeleted, hash FROM api_tokens; - -DROP TABLE api_tokens; -ALTER TABLE api_tokens_mig RENAME TO api_tokens; - -CREATE TABLE IF NOT EXISTS "branches_mig" ( - `branchId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `parentNoteId` TEXT NOT NULL, - `notePosition` INTEGER NOT NULL, - `prefix` TEXT, - `isExpanded` BOOLEAN, - `isDeleted` INTEGER NOT NULL DEFAULT 0, - `utcDateModified` TEXT NOT NULL, - utcDateCreated TEXT NOT NULL, - hash TEXT DEFAULT "" NOT NULL, - PRIMARY KEY(`branchId`) -); - -INSERT INTO branches_mig (branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, utcDateModified, utcDateCreated, hash) - SELECT branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, REPLACE(dateModified, 'T', ' '), REPLACE(dateCreated, 'T', ' '), hash FROM branches; - -DROP TABLE branches; -ALTER TABLE branches_mig RENAME TO branches; - -CREATE TABLE IF NOT EXISTS "recent_notes_mig" ( - `branchId` TEXT NOT NULL PRIMARY KEY, - `notePath` TEXT NOT NULL, - hash TEXT DEFAULT "" NOT NULL, - `utcDateCreated` TEXT NOT NULL, - isDeleted INT -); - -INSERT INTO recent_notes_mig (branchId, notePath, hash, utcDateCreated, isDeleted) - SELECT branchId, notePath, hash, REPLACE(dateCreated, 'T', ' '), isDeleted FROM recent_notes; - -DROP TABLE recent_notes; -ALTER TABLE recent_notes_mig RENAME TO recent_notes; - -CREATE TABLE IF NOT EXISTS "event_log_mig" ( - `eventId` TEXT NOT NULL PRIMARY KEY, - `noteId` TEXT, - `comment` TEXT, - `utcDateCreated` TEXT NOT NULL -); - -INSERT INTO event_log_mig (eventId, noteId, comment, utcDateCreated) - SELECT eventId, noteId, comment, REPLACE(dateCreated, 'T', ' ') FROM event_log; - -DROP TABLE event_log; -ALTER TABLE event_log_mig RENAME TO event_log; - -CREATE TABLE IF NOT EXISTS "options_mig" -( - name TEXT not null PRIMARY KEY, - value TEXT, - isSynced INTEGER default 0 not null, - hash TEXT default "" not null, - utcDateCreated TEXT not null, - utcDateModified TEXT NOT NULL -); - -INSERT INTO options_mig (name, value, isSynced, hash, utcDateCreated, utcDateModified) - SELECT name, value, isSynced, hash, REPLACE(dateCreated, 'T', ' '), REPLACE(dateModified, 'T', ' ') FROM options; - -DROP TABLE options; -ALTER TABLE options_mig RENAME TO options; - -CREATE TABLE attributes_mig -( - attributeId TEXT not null primary key, - noteId TEXT not null, - type TEXT not null, - name TEXT not null, - value TEXT default '' not null, - position INT default 0 not null, - utcDateCreated TEXT not null, - utcDateModified TEXT not null, - isDeleted INT not null, - hash TEXT default "" not null, - isInheritable int DEFAULT 0 NULL); - -INSERT INTO attributes_mig (attributeId, noteId, type, name, value, position, utcDateCreated, utcDateModified, isDeleted, hash, isInheritable) - SELECT attributeId, noteId, type, name, value, position, REPLACE(dateCreated, 'T', ' '), REPLACE(dateModified, 'T', ' '), isDeleted, hash, isInheritable FROM attributes; - -DROP TABLE attributes; -ALTER TABLE attributes_mig RENAME TO attributes; - -CREATE TABLE IF NOT EXISTS "links_mig" ( - `linkId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `targetNoteId` TEXT NOT NULL, - `type` TEXT NOT NULL, - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INTEGER NOT NULL DEFAULT 0, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`linkId`) -); - -INSERT INTO links_mig (linkId, noteId, targetNoteId, type, hash, isDeleted, utcDateCreated, utcDateModified) - SELECT linkId, noteId, targetNoteId, type, hash, isDeleted, REPLACE(dateCreated, 'T', ' '), REPLACE(dateModified, 'T', ' ') FROM links; - -DROP TABLE links; -ALTER TABLE links_mig RENAME TO links; - -CREATE TABLE IF NOT EXISTS "note_contents_mig" ( - `noteContentId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `isProtected` INT NOT NULL DEFAULT 0, - `content` TEXT NULL DEFAULT NULL, - `hash` TEXT DEFAULT "" NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteContentId`) -); - -INSERT INTO note_contents_mig (noteContentId, noteId, isProtected, content, hash, utcDateCreated, utcDateModified) - SELECT noteContentId, noteId, isProtected, content, hash, REPLACE(dateCreated, 'T', ' '), REPLACE(dateModified, 'T', ' ') FROM note_contents; - -DROP TABLE note_contents; -ALTER TABLE note_contents_mig RENAME TO note_contents; - -CREATE TABLE IF NOT EXISTS "notes_mig" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INT NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`) -); - -INSERT INTO notes_mig (noteId, title, isProtected, type, mime, hash, isDeleted, dateCreated, dateModified, utcDateCreated, utcDateModified) - SELECT noteId, title, isProtected, type, mime, hash, isDeleted, REPLACE(REPLACE(dateCreated, 'T', ' '), 'Z', '+0000'), REPLACE(REPLACE(dateModified, 'T', ' '), 'Z', '+0000'), REPLACE(dateCreated, 'T', ' '), REPLACE(dateModified, 'T', ' ') FROM notes; - -DROP TABLE notes; -ALTER TABLE notes_mig RENAME TO notes; - -CREATE UNIQUE INDEX `IDX_sync_entityName_entityId` ON `sync` ( - `entityName`, - `entityId` - ); -CREATE INDEX `IDX_sync_utcSyncDate` ON `sync` ( - `utcSyncDate` - ); -CREATE INDEX `IDX_note_revisions_noteId` ON `note_revisions` ( - `noteId` - ); -CREATE INDEX `IDX_note_revisions_dateModifiedFrom` ON `note_revisions` ( - `utcDateModifiedFrom` - ); -CREATE INDEX `IDX_note_revisions_dateModifiedTo` ON `note_revisions` ( - `utcDateModifiedTo` - ); -CREATE INDEX `IDX_branches_noteId` ON `branches` ( - `noteId` - ); -CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` ( - `noteId`, - `parentNoteId` - ); -CREATE INDEX IDX_branches_parentNoteId ON branches (parentNoteId); -CREATE INDEX IDX_attributes_name_value - on attributes (name, value); -CREATE INDEX IDX_links_noteId_index - on links (noteId); -CREATE INDEX IDX_links_targetNoteId_index - on links (targetNoteId); -CREATE INDEX IDX_attributes_name_index - on attributes (name); -CREATE INDEX IDX_attributes_noteId_index - on attributes (noteId); -CREATE INDEX IDX_attributes_value_index - on attributes (value); -CREATE UNIQUE INDEX `IDX_note_contents_noteId` ON `note_contents` (`noteId`); diff --git a/db/migrations/0131__cleanup_note_contents.sql b/db/migrations/0131__cleanup_note_contents.sql deleted file mode 100644 index 7663b181c..000000000 --- a/db/migrations/0131__cleanup_note_contents.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE IF NOT EXISTS "note_contents_mig" ( - `noteId` TEXT NOT NULL, - `content` TEXT NULL DEFAULT NULL, - `hash` TEXT DEFAULT "" NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`) -); - -INSERT INTO note_contents_mig (noteId, content, hash, utcDateModified) -SELECT noteId, content, hash, utcDateModified FROM note_contents; - -DROP TABLE note_contents; -ALTER TABLE note_contents_mig RENAME TO note_contents; diff --git a/db/migrations/0132__fill_sync.js b/db/migrations/0132__fill_sync.js deleted file mode 100644 index 41519ea2e..000000000 --- a/db/migrations/0132__fill_sync.js +++ /dev/null @@ -1,5 +0,0 @@ -const syncTableService = require('../../src/services/entity_changes.js'); - -module.exports = async () => { - await syncTableService.fillAllSyncRows(); -}; diff --git a/db/migrations/0133__drop_note_fulltext.sql b/db/migrations/0133__drop_note_fulltext.sql deleted file mode 100644 index 775842874..000000000 --- a/db/migrations/0133__drop_note_fulltext.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS note_fulltext; \ No newline at end of file diff --git a/db/migrations/0134__create_openTabs_option.sql b/db/migrations/0134__create_openTabs_option.sql deleted file mode 100644 index acad843ce..000000000 --- a/db/migrations/0134__create_openTabs_option.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) - SELECT 'openTabs', '[{"notePath":"' || value || '","active": true,"tabId":"1111"}]', '2019-05-01T18:31:00.874Z', '2019-05-01T18:31:00.874Z', 0 FROM options WHERE name = 'startNotePath'; - -DELETE FROM options WHERE name = 'startNotePath'; diff --git a/db/migrations/0135__add_hideTabRowForOneTab_option.sql b/db/migrations/0135__add_hideTabRowForOneTab_option.sql deleted file mode 100644 index 2eff060c5..000000000 --- a/db/migrations/0135__add_hideTabRowForOneTab_option.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) - VALUES ('hideTabRowForOneTab', 'false', '2019-05-01T18:31:00.874Z', '2019-05-01T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0136__update_recent_notes.sql b/db/migrations/0136__update_recent_notes.sql deleted file mode 100644 index c3397597f..000000000 --- a/db/migrations/0136__update_recent_notes.sql +++ /dev/null @@ -1,12 +0,0 @@ -drop table recent_notes; - -create table recent_notes -( - noteId TEXT not null primary key, - notePath TEXT not null, - hash TEXT default "" not null, - utcDateCreated TEXT not null, - isDeleted INT -); - -delete from sync where entityName = 'recent_notes'; \ No newline at end of file diff --git a/db/migrations/0137__links_to_attributes.sql b/db/migrations/0137__links_to_attributes.sql deleted file mode 100644 index 294debe34..000000000 --- a/db/migrations/0137__links_to_attributes.sql +++ /dev/null @@ -1,10 +0,0 @@ -UPDATE links SET type = 'internal-link' WHERE type = 'hyper'; -UPDATE links SET type = 'image-link' WHERE type = 'image'; -UPDATE links SET type = 'relation-map-link' WHERE type = 'relation-map'; - -INSERT INTO attributes (attributeId, noteId, type, name, value, position, utcDateCreated, utcDateModified, isDeleted, hash, isInheritable) -SELECT linkId, noteId, 'relation', type, targetNoteId, 0, utcDateCreated, utcDateModified, isDeleted, hash, 0 FROM links; - -UPDATE sync SET entityName = 'attributes' WHERE entityName = 'links'; - -DROP TABLE links; \ No newline at end of file diff --git a/db/migrations/0138__sidebar_sizing.sql b/db/migrations/0138__sidebar_sizing.sql deleted file mode 100644 index 2ecb582d4..000000000 --- a/db/migrations/0138__sidebar_sizing.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('sidebarMinWidth', '350', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); - -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('sidebarWidthPercent', '25', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0139__show_sidebar_in_new_tab.sql b/db/migrations/0139__show_sidebar_in_new_tab.sql deleted file mode 100644 index 5150630dc..000000000 --- a/db/migrations/0139__show_sidebar_in_new_tab.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('showSidebarInNewTab', 'true', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0140__widget_config.sql b/db/migrations/0140__widget_config.sql deleted file mode 100644 index c371443b8..000000000 --- a/db/migrations/0140__widget_config.sql +++ /dev/null @@ -1,14 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('noteInfoWidget', '{"enabled":true,"expanded":true,"position":100}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); - -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('attributesWidget', '{"enabled":true,"expanded":true,"position":200}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); - -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('linkMapWidget', '{"enabled":true,"expanded":true,"position":300}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); - -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('noteRevisionsWidget', '{"enabled":true,"expanded":true,"position":400}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); - -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('whatLinksHereWidget', '{"enabled":false,"expanded":true,"position":500}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0141__add_code_note_mime_types.sql b/db/migrations/0141__add_code_note_mime_types.sql deleted file mode 100644 index 55aac14b9..000000000 --- a/db/migrations/0141__add_code_note_mime_types.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('codeNotesMimeTypes', '["text/x-csrc","text/x-c++src","text/x-csharp","text/css","text/x-go","text/x-groovy","text/x-haskell","text/html","message/http","text/x-java","application/javascript;env=frontend","application/javascript;env=backend","application/json","text/x-kotlin","text/x-markdown","text/x-perl","text/x-php","text/x-python","text/x-ruby",null,"text/x-sql","text/x-swift","text/xml","text/x-yaml"]', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 1); - -INSERT INTO sync (entityName, entityId, sourceId, utcSyncDate) -VALUES ('options' ,'codeNotesMimeTypes', 'SYNC_FILL', '2018-01-01T00:00:00.000Z'); \ No newline at end of file diff --git a/db/migrations/0142__similar_notes_widget.sql b/db/migrations/0142__similar_notes_widget.sql deleted file mode 100644 index 3467cb4c6..000000000 --- a/db/migrations/0142__similar_notes_widget.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('similarNotesWidget', '{"enabled":true,"expanded":true,"position":600}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0143__drop_event_log.sql b/db/migrations/0143__drop_event_log.sql deleted file mode 100644 index 3996548c5..000000000 --- a/db/migrations/0143__drop_event_log.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE event_log; \ No newline at end of file diff --git a/db/migrations/0144__edited_notes_widget.sql b/db/migrations/0144__edited_notes_widget.sql deleted file mode 100644 index 00a38f75f..000000000 --- a/db/migrations/0144__edited_notes_widget.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('editedNotesWidget', '{"enabled":true,"expanded":true,"position":50}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0145__calendar_widget.sql b/db/migrations/0145__calendar_widget.sql deleted file mode 100644 index 818929c2f..000000000 --- a/db/migrations/0145__calendar_widget.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('calendarWidget', '{"enabled":true,"expanded":true,"position":20}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0146__add_spell_check_options.sql b/db/migrations/0146__add_spell_check_options.sql deleted file mode 100644 index 7f2378f39..000000000 --- a/db/migrations/0146__add_spell_check_options.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('spellCheckEnabled', 'true', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); - -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -VALUES ('spellCheckLanguageCode', 'en-US', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); \ No newline at end of file diff --git a/db/migrations/0147__add_hideTabRowForOneTab_if_missing.sql b/db/migrations/0147__add_hideTabRowForOneTab_if_missing.sql deleted file mode 100644 index 69f6620b0..000000000 --- a/db/migrations/0147__add_hideTabRowForOneTab_if_missing.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) -SELECT 'hideTabRowForOneTab', 'false', '2019-05-01T18:31:00.874Z', '2019-05-01T18:31:00.874Z', 0 -WHERE NOT EXISTS(SELECT 1 FROM options WHERE name = 'hideTabRowForOneTab'); \ No newline at end of file diff --git a/db/migrations/0148__make_isExpanded_not_null.sql b/db/migrations/0148__make_isExpanded_not_null.sql deleted file mode 100644 index 357716a23..000000000 --- a/db/migrations/0148__make_isExpanded_not_null.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE IF NOT EXISTS "mig_branches" ( - `branchId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `parentNoteId` TEXT NOT NULL, - `notePosition` INTEGER NOT NULL, - `prefix` TEXT, - `isExpanded` INTEGER NOT NULL DEFAULT 0, - `isDeleted` INTEGER NOT NULL DEFAULT 0, - `utcDateModified` TEXT NOT NULL, - utcDateCreated TEXT NOT NULL, - hash TEXT DEFAULT "" NOT NULL, - PRIMARY KEY(`branchId`)); - -INSERT INTO mig_branches (branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, utcDateModified, utcDateCreated, hash) -SELECT branchId, noteId, parentNoteId, notePosition, prefix, COALESCE(isExpanded, 0), isDeleted, utcDateModified, utcDateCreated, hash FROM branches; - -DROP TABLE branches; -ALTER TABLE mig_branches RENAME TO branches; - -CREATE INDEX `IDX_branches_noteId` ON `branches` (`noteId`); -CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` (`noteId`,`parentNoteId`); -CREATE INDEX IDX_branches_parentNoteId ON branches (parentNoteId); \ No newline at end of file diff --git a/db/migrations/0149__space_out_positions.sql b/db/migrations/0149__space_out_positions.sql deleted file mode 100644 index 0f8bbb6e9..000000000 --- a/db/migrations/0149__space_out_positions.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE branches SET notePosition = notePosition * 10; -UPDATE attributes SET position = position * 10; \ No newline at end of file diff --git a/db/migrations/0150__note_revision_contents.sql b/db/migrations/0150__note_revision_contents.sql deleted file mode 100644 index 6f3cf2b9a..000000000 --- a/db/migrations/0150__note_revision_contents.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE IF NOT EXISTS "note_revisions_mig" (`noteRevisionId` TEXT NOT NULL PRIMARY KEY, - `noteId` TEXT NOT NULL, - `title` TEXT, - `contentLength` INT NOT NULL, - `isProtected` INT NOT NULL DEFAULT 0, - `utcDateLastEdited` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - `dateLastEdited` TEXT NOT NULL, - `dateCreated` TEXT NOT NULL, - type TEXT DEFAULT '' NOT NULL, - mime TEXT DEFAULT '' NOT NULL, - hash TEXT DEFAULT '' NOT NULL); - -CREATE TABLE IF NOT EXISTS "note_revision_contents" (`noteRevisionId` TEXT NOT NULL PRIMARY KEY, - `content` TEXT, - hash TEXT DEFAULT '' NOT NULL, - `utcDateModified` TEXT NOT NULL); - -INSERT INTO note_revision_contents (noteRevisionId, content, hash, utcDateModified) -SELECT noteRevisionId, content, hash, utcDateModifiedTo FROM note_revisions; - -INSERT INTO note_revisions_mig (noteRevisionId, noteId, title, contentLength, isProtected, utcDateLastEdited, utcDateCreated, utcDateModified, dateLastEdited, dateCreated, type, mime, hash) -SELECT noteRevisionId, noteId, title, COALESCE(LENGTH(content), 0), isProtected, utcDateModifiedFrom, utcDateModifiedTo, utcDateModifiedTo, dateModifiedFrom, dateModifiedTo, type, mime, hash FROM note_revisions; - -DROP TABLE note_revisions; -ALTER TABLE note_revisions_mig RENAME TO note_revisions; - -CREATE INDEX `IDX_note_revisions_noteId` ON `note_revisions` (`noteId`); -CREATE INDEX `IDX_note_revisions_utcDateCreated` ON `note_revisions` (`utcDateCreated`); -CREATE INDEX `IDX_note_revisions_utcDateLastEdited` ON `note_revisions` (`utcDateLastEdited`); -CREATE INDEX `IDX_note_revisions_dateCreated` ON `note_revisions` (`dateCreated`); -CREATE INDEX `IDX_note_revisions_dateLastEdited` ON `note_revisions` (`dateLastEdited`); - -INSERT INTO sync (entityName, entityId, sourceId, utcSyncDate) -SELECT 'note_revision_contents', entityId, sourceId, utcSyncDate FROM sync WHERE entityName = 'note_revisions'; \ No newline at end of file diff --git a/db/migrations/0151__add_isErased_to_note.sql b/db/migrations/0151__add_isErased_to_note.sql deleted file mode 100644 index ae996c6ab..000000000 --- a/db/migrations/0151__add_isErased_to_note.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE IF NOT EXISTS "notes_mig" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INT NOT NULL DEFAULT 0, - `isErased` INT NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`)); - -INSERT INTO notes_mig (noteId, title, isProtected, type, mime, hash, isDeleted, isErased, dateCreated, dateModified, utcDateCreated, utcDateModified) -SELECT noteId, title, isProtected, type, mime, hash, isDeleted, 0, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes; - -DROP TABLE notes; -ALTER TABLE notes_mig RENAME TO notes; - -UPDATE notes SET isErased = 1 WHERE isDeleted = 1 -AND 1=(SELECT CASE WHEN content IS NULL THEN 1 ELSE 0 END FROM note_contents WHERE note_contents.noteId = notes.noteId); - -CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); -CREATE INDEX `IDX_notes_title` ON `notes` (`title`); -CREATE INDEX `IDX_notes_type` ON `notes` (`type`); -CREATE INDEX `IDX_notes_dateCreated` ON `notes` (`dateCreated`); -CREATE INDEX `IDX_notes_dateModified` ON `notes` (`dateModified`); -CREATE INDEX `IDX_notes_utcDateModified` ON `notes` (`utcDateModified`); -CREATE INDEX `IDX_notes_utcDateCreated` ON `notes` (`utcDateCreated`); \ No newline at end of file diff --git a/db/migrations/0152__add_contentLength_to_note.sql b/db/migrations/0152__add_contentLength_to_note.sql deleted file mode 100644 index 60e38df86..000000000 --- a/db/migrations/0152__add_contentLength_to_note.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE IF NOT EXISTS "notes_mig" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `contentLength` INT NOT NULL, - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INT NOT NULL DEFAULT 0, - `isErased` INT NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`)); - -INSERT INTO notes_mig (noteId, title, contentLength, isProtected, type, mime, hash, isDeleted, isErased, dateCreated, dateModified, utcDateCreated, utcDateModified) -SELECT noteId, title, -1, isProtected, type, mime, hash, isDeleted, isErased, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes; - -DROP TABLE notes; -ALTER TABLE notes_mig RENAME TO notes; - -UPDATE notes SET contentLength = COALESCE((SELECT COALESCE(LENGTH(content), 0) FROM note_contents WHERE note_contents.noteId = notes.noteId), -1); - -CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); -CREATE INDEX `IDX_notes_title` ON `notes` (`title`); -CREATE INDEX `IDX_notes_type` ON `notes` (`type`); -CREATE INDEX `IDX_notes_dateCreated` ON `notes` (`dateCreated`); -CREATE INDEX `IDX_notes_dateModified` ON `notes` (`dateModified`); -CREATE INDEX `IDX_notes_utcDateModified` ON `notes` (`utcDateModified`); -CREATE INDEX `IDX_notes_utcDateCreated` ON `notes` (`utcDateCreated`); - --- should be OK since sync protocol changes so all instances must upgrade -UPDATE attributes SET isDeleted = 1 WHERE name = 'fileSize'; \ No newline at end of file diff --git a/db/migrations/0153__add_isErased_to_note_revision.sql b/db/migrations/0153__add_isErased_to_note_revision.sql deleted file mode 100644 index 7d3559088..000000000 --- a/db/migrations/0153__add_isErased_to_note_revision.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE IF NOT EXISTS "note_revisions_mig" (`noteRevisionId` TEXT NOT NULL PRIMARY KEY, - `noteId` TEXT NOT NULL, - `title` TEXT, - `contentLength` INT NOT NULL, - `isErased` INT NOT NULL DEFAULT 0, - `isProtected` INT NOT NULL DEFAULT 0, - `utcDateLastEdited` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - `dateLastEdited` TEXT NOT NULL, - `dateCreated` TEXT NOT NULL, - type TEXT DEFAULT '' NOT NULL, - mime TEXT DEFAULT '' NOT NULL, - hash TEXT DEFAULT '' NOT NULL); - -INSERT INTO note_revisions_mig (noteRevisionId, noteId, title, contentLength, isErased, isProtected, utcDateLastEdited, utcDateCreated, utcDateModified, dateLastEdited, dateCreated, type, mime, hash) -SELECT noteRevisionId, noteId, title, contentLength, 0, isProtected, utcDateLastEdited, utcDateCreated, utcDateModified, dateLastEdited, dateCreated, type, mime, hash FROM note_revisions; - -DROP TABLE note_revisions; -ALTER TABLE note_revisions_mig RENAME TO note_revisions; - -UPDATE note_revisions SET isErased = (SELECT isErased FROM notes WHERE notes.noteId = note_revisions.noteId); - -CREATE INDEX `IDX_note_revisions_noteId` ON `note_revisions` (`noteId`); -CREATE INDEX `IDX_note_revisions_utcDateCreated` ON `note_revisions` (`utcDateCreated`); -CREATE INDEX `IDX_note_revisions_utcDateLastEdited` ON `note_revisions` (`utcDateLastEdited`); -CREATE INDEX `IDX_note_revisions_dateCreated` ON `note_revisions` (`dateCreated`); -CREATE INDEX `IDX_note_revisions_dateLastEdited` ON `note_revisions` (`dateLastEdited`); \ No newline at end of file diff --git a/db/migrations/0154__system_links_should_follow_camelCase.sql b/db/migrations/0154__system_links_should_follow_camelCase.sql deleted file mode 100644 index d0519ef7d..000000000 --- a/db/migrations/0154__system_links_should_follow_camelCase.sql +++ /dev/null @@ -1,3 +0,0 @@ -UPDATE attributes SET name = 'internalLink' WHERE name = 'internal-link'; -UPDATE attributes SET name = 'imageLink' WHERE name = 'image-link'; -UPDATE attributes SET name = 'relationMapLink' WHERE name = 'relation-map-link'; \ No newline at end of file diff --git a/db/migrations/0155__indexes.sql b/db/migrations/0155__indexes.sql deleted file mode 100644 index dd523a35a..000000000 --- a/db/migrations/0155__indexes.sql +++ /dev/null @@ -1,5 +0,0 @@ -DROP INDEX IF EXISTS IDX_attributes_name_index; -DROP INDEX IF EXISTS IDX_branches_noteId; - -CREATE INDEX IDX_source_ids_utcDateCreated - on source_ids (utcDateCreated); \ No newline at end of file diff --git a/db/migrations/0156__add_deleteId.sql b/db/migrations/0156__add_deleteId.sql deleted file mode 100644 index dc7ea2182..000000000 --- a/db/migrations/0156__add_deleteId.sql +++ /dev/null @@ -1,81 +0,0 @@ -CREATE TABLE IF NOT EXISTS "notes_mig" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `contentLength` INT NOT NULL, - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INT NOT NULL DEFAULT 0, - `deleteId` TEXT DEFAULT NULL, - `isErased` INT NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`)); - -INSERT INTO notes_mig (noteId, title, contentLength, isProtected, type, mime, hash, isDeleted, isErased, dateCreated, dateModified, utcDateCreated, utcDateModified) -SELECT noteId, title, -1, isProtected, type, mime, hash, isDeleted, isErased, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes; - -DROP TABLE notes; -ALTER TABLE notes_mig RENAME TO notes; - -CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); -CREATE INDEX `IDX_notes_title` ON `notes` (`title`); -CREATE INDEX `IDX_notes_type` ON `notes` (`type`); -CREATE INDEX `IDX_notes_dateCreated` ON `notes` (`dateCreated`); -CREATE INDEX `IDX_notes_dateModified` ON `notes` (`dateModified`); -CREATE INDEX `IDX_notes_utcDateModified` ON `notes` (`utcDateModified`); -CREATE INDEX `IDX_notes_utcDateCreated` ON `notes` (`utcDateCreated`); - -CREATE TABLE IF NOT EXISTS "branches_mig" ( - `branchId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `parentNoteId` TEXT NOT NULL, - `notePosition` INTEGER NOT NULL, - `prefix` TEXT, - `isExpanded` INTEGER NOT NULL DEFAULT 0, - `isDeleted` INTEGER NOT NULL DEFAULT 0, - `deleteId` TEXT DEFAULT NULL, - `utcDateModified` TEXT NOT NULL, - utcDateCreated TEXT NOT NULL, - hash TEXT DEFAULT "" NOT NULL, - PRIMARY KEY(`branchId`)); - -INSERT INTO branches_mig (branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, utcDateModified, utcDateCreated, hash) - SELECT branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, utcDateModified, utcDateCreated, hash FROM branches; - -DROP TABLE branches; -ALTER TABLE branches_mig RENAME TO branches; - -CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` (`noteId`,`parentNoteId`); -CREATE INDEX IDX_branches_parentNoteId ON branches (parentNoteId); - -CREATE TABLE IF NOT EXISTS "attributes_mig" -( - attributeId TEXT not null primary key, - noteId TEXT not null, - type TEXT not null, - name TEXT not null, - value TEXT default '' not null, - position INT default 0 not null, - utcDateCreated TEXT not null, - utcDateModified TEXT not null, - isDeleted INT not null, - `deleteId` TEXT DEFAULT NULL, - hash TEXT default "" not null, - isInheritable int DEFAULT 0 NULL); - -INSERT INTO attributes_mig (attributeId, noteId, type, name, value, position, utcDateCreated, utcDateModified, isDeleted, hash, isInheritable) -SELECT attributeId, noteId, type, name, value, position, utcDateCreated, utcDateModified, isDeleted, hash, isInheritable FROM attributes; - -DROP TABLE attributes; -ALTER TABLE attributes_mig RENAME TO attributes; - -CREATE INDEX IDX_attributes_name_value - on attributes (name, value); -CREATE INDEX IDX_attributes_noteId_index - on attributes (noteId); -CREATE INDEX IDX_attributes_value_index - on attributes (value); diff --git a/db/migrations/0157__fix_contentLength.sql b/db/migrations/0157__fix_contentLength.sql deleted file mode 100644 index 63bb6ad35..000000000 --- a/db/migrations/0157__fix_contentLength.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE notes SET contentLength = COALESCE((SELECT COALESCE(LENGTH(content), 0) FROM note_contents WHERE note_contents.noteId = notes.noteId), -1); \ No newline at end of file diff --git a/db/migrations/0158__add_isSynced_to_sync.sql b/db/migrations/0158__add_isSynced_to_sync.sql deleted file mode 100644 index 647815f98..000000000 --- a/db/migrations/0158__add_isSynced_to_sync.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE IF NOT EXISTS "sync_mig" ( - `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `entityName` TEXT NOT NULL, - `entityId` TEXT NOT NULL, - `sourceId` TEXT NOT NULL, - `isSynced` INTEGER default 0 not null, - `utcSyncDate` TEXT NOT NULL); - -INSERT INTO sync_mig (id, entityName, entityId, sourceId, isSynced, utcSyncDate) -SELECT id, entityName, entityId, sourceId, 1, utcSyncDate FROM sync; - -DROP TABLE sync; - -ALTER TABLE sync_mig RENAME TO sync; - -CREATE UNIQUE INDEX `IDX_sync_entityName_entityId` ON `sync` ( - `entityName`, - `entityId` - ); -CREATE INDEX `IDX_sync_utcSyncDate` ON `sync` ( - `utcSyncDate` - ); \ No newline at end of file diff --git a/db/migrations/0159__fix_isSynced_in_sync_rows.sql b/db/migrations/0159__fix_isSynced_in_sync_rows.sql deleted file mode 100644 index 82f22b9ef..000000000 --- a/db/migrations/0159__fix_isSynced_in_sync_rows.sql +++ /dev/null @@ -1,4 +0,0 @@ -UPDATE sync SET isSynced = 1 WHERE entityName != 'options' OR ( - entityName = 'options' - AND 1 = (SELECT isSynced FROM options WHERE name = sync.entityId) - ) diff --git a/db/migrations/0160__migrate_attr_definitions.sql b/db/migrations/0160__migrate_attr_definitions.sql deleted file mode 100644 index 8ed5419db..000000000 --- a/db/migrations/0160__migrate_attr_definitions.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE attributes SET type = 'label', name = 'label:' || name WHERE type = 'label-definition'; -UPDATE attributes SET type = 'label', name = 'relation:' || name WHERE type = 'relation-definition'; diff --git a/db/migrations/0161__attr_def_short.js b/db/migrations/0161__attr_def_short.js deleted file mode 100644 index fcccabaf6..000000000 --- a/db/migrations/0161__attr_def_short.js +++ /dev/null @@ -1,79 +0,0 @@ -const sql = require('../../src/services/sql'); - -module.exports = () => { - for (const attr of sql.getRows("SELECT * FROM attributes WHERE name LIKE 'label:%'")) { - let obj; - - try { - obj = JSON.parse(attr.value); - } - catch (e) { - console.log(`Parsing attribute definition "${attr.value}" of ${attr.attributeId} failed with error "${e.message}", setting to default value.`); - - sql.execute('UPDATE attributes SET value = ? WHERE attributeId = ?', - ["multi,text", attr.attributeId]); - - continue; - } - - const tokens = []; - - if (obj.isPromoted) { - tokens.push('promoted'); - } - - if (obj.multiplicityType === 'singlevalue') { - tokens.push('single'); - } else if (obj.multiplicityType === 'multivalue') { - tokens.push('multi'); - } - - if (obj.labelType) { - tokens.push(obj.labelType); - } - - if (obj.numberPrecision) { - tokens.push('precision='+obj.numberPrecision); - } - - const newValue = tokens.join(','); - - sql.execute('UPDATE attributes SET value = ? WHERE attributeId = ?', [newValue, attr.attributeId]); - } - - for (const attr of sql.getRows("SELECT * FROM attributes WHERE name LIKE 'relation:%'")) { - let obj; - - try { - obj = JSON.parse(attr.value); - } - catch (e) { - console.log(`Parsing attribute definition "${attr.value}" of ${attr.attributeId} failed with error "${e.message}", setting to default value.`); - - sql.execute('UPDATE attributes SET value = ? WHERE attributeId = ?', - ["multi", attr.attributeId]); - - continue; - } - - const tokens = []; - - if (obj.isPromoted) { - tokens.push('promoted'); - } - - if (obj.multiplicityType === 'singlevalue') { - tokens.push('single'); - } else if (obj.multiplicityType === 'multivalue') { - tokens.push('multi'); - } - - if (obj.inverseRelation) { - tokens.push('inverse=' + obj.inverseRelation); - } - - const newValue = tokens.join(','); - - sql.execute('UPDATE attributes SET value = ? WHERE attributeId = ?', [newValue, attr.attributeId]); - } -}; diff --git a/db/migrations/0162__drop_source_ids.sql b/db/migrations/0162__drop_source_ids.sql deleted file mode 100644 index 78821337e..000000000 --- a/db/migrations/0162__drop_source_ids.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE source_ids; diff --git a/db/migrations/0163__rename_sync_to_entity_changes.sql b/db/migrations/0163__rename_sync_to_entity_changes.sql deleted file mode 100644 index 431c45849..000000000 --- a/db/migrations/0163__rename_sync_to_entity_changes.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE sync RENAME TO entity_changes; diff --git a/db/migrations/0164__rename_utcSyncDate.sql b/db/migrations/0164__rename_utcSyncDate.sql deleted file mode 100644 index e0bd1ff1e..000000000 --- a/db/migrations/0164__rename_utcSyncDate.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( - `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `entityName` TEXT NOT NULL, - `entityId` TEXT NOT NULL, - `sourceId` TEXT NOT NULL, - `isSynced` INTEGER default 0 not null, - `utcChangedDate` TEXT NOT NULL); - -INSERT INTO mig_entity_changes (id, entityName, entityId, sourceId, isSynced, utcChangedDate) - SELECT id, entityName, entityId, sourceId, isSynced, utcSyncDate FROM entity_changes; - -DROP TABLE entity_changes; - -ALTER TABLE mig_entity_changes RENAME TO entity_changes; - -CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes" ( - `entityName`, - `entityId` - ); -CREATE INDEX `IDX_entityChanges_utcChangedDate` ON "entity_changes" ( - `utcChangedDate` - ); diff --git a/db/migrations/0165__move_contentLength.sql b/db/migrations/0165__move_contentLength.sql deleted file mode 100644 index cae0d2895..000000000 --- a/db/migrations/0165__move_contentLength.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE TABLE IF NOT EXISTS "notes_mig" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `hash` TEXT DEFAULT "" NOT NULL, - `isDeleted` INT NOT NULL DEFAULT 0, - `deleteId` TEXT DEFAULT NULL, - `isErased` INT NOT NULL DEFAULT 0, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`)); - -INSERT INTO notes_mig (noteId, title, isProtected, type, mime, hash, isDeleted, deleteId, isErased, dateCreated, dateModified, utcDateCreated, utcDateModified) - SELECT noteId, title, isProtected, type, mime, hash, isDeleted, deleteId, isErased, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes; - -DROP TABLE notes; -ALTER TABLE notes_mig RENAME TO notes; - -CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); -CREATE INDEX `IDX_notes_title` ON `notes` (`title`); -CREATE INDEX `IDX_notes_type` ON `notes` (`type`); -CREATE INDEX `IDX_notes_dateCreated` ON `notes` (`dateCreated`); -CREATE INDEX `IDX_notes_dateModified` ON `notes` (`dateModified`); -CREATE INDEX `IDX_notes_utcDateModified` ON `notes` (`utcDateModified`); -CREATE INDEX `IDX_notes_utcDateCreated` ON `notes` (`utcDateCreated`); - -CREATE TABLE IF NOT EXISTS "note_revisions_mig" (`noteRevisionId` TEXT NOT NULL PRIMARY KEY, - `noteId` TEXT NOT NULL, - `title` TEXT, - `isErased` INT NOT NULL DEFAULT 0, - `isProtected` INT NOT NULL DEFAULT 0, - `utcDateLastEdited` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - `dateLastEdited` TEXT NOT NULL, - `dateCreated` TEXT NOT NULL, - type TEXT DEFAULT '' NOT NULL, - mime TEXT DEFAULT '' NOT NULL, - hash TEXT DEFAULT '' NOT NULL); - -INSERT INTO note_revisions_mig (noteRevisionId, noteId, title, isErased, isProtected, utcDateLastEdited, utcDateCreated, utcDateModified, dateLastEdited, dateCreated, type, mime, hash) -SELECT noteRevisionId, noteId, title, isErased, isProtected, utcDateLastEdited, utcDateCreated, utcDateModified, dateLastEdited, dateCreated, type, mime, hash FROM note_revisions; - -DROP TABLE note_revisions; -ALTER TABLE note_revisions_mig RENAME TO note_revisions; - -CREATE INDEX `IDX_note_revisions_noteId` ON `note_revisions` (`noteId`); -CREATE INDEX `IDX_note_revisions_utcDateCreated` ON `note_revisions` (`utcDateCreated`); -CREATE INDEX `IDX_note_revisions_utcDateLastEdited` ON `note_revisions` (`utcDateLastEdited`); -CREATE INDEX `IDX_note_revisions_dateCreated` ON `note_revisions` (`dateCreated`); -CREATE INDEX `IDX_note_revisions_dateLastEdited` ON `note_revisions` (`dateLastEdited`); diff --git a/db/migrations/0166__add_dateModified_to_note_content.sql b/db/migrations/0166__add_dateModified_to_note_content.sql deleted file mode 100644 index f42ecaa01..000000000 --- a/db/migrations/0166__add_dateModified_to_note_content.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE IF NOT EXISTS "note_contents_mig" ( - `noteId` TEXT NOT NULL, - `content` TEXT NULL DEFAULT NULL, - `hash` TEXT DEFAULT "" NOT NULL, - `dateModified` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`) -); - -INSERT INTO note_contents_mig (noteId, content, hash, dateModified, utcDateModified) - SELECT noteId, - content, - hash, - COALESCE((SELECT dateModified FROM notes WHERE noteId = note_contents.noteId), utcDateModified), - utcDateModified - FROM note_contents; - -DROP TABLE note_contents; - -ALTER TABLE note_contents_mig RENAME TO note_contents; diff --git a/db/migrations/0167__remove_activateParentNote.sql b/db/migrations/0167__remove_activateParentNote.sql deleted file mode 100644 index a16956905..000000000 --- a/db/migrations/0167__remove_activateParentNote.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM options WHERE name = 'keyboardShortcutsActivateParentNote'; diff --git a/db/migrations/0168__rename_hideInAutocomplete_to_archived.sql b/db/migrations/0168__rename_hideInAutocomplete_to_archived.sql deleted file mode 100644 index 29b72138c..000000000 --- a/db/migrations/0168__rename_hideInAutocomplete_to_archived.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE attributes SET name = 'archived' WHERE name = 'hideInAutocomplete'; diff --git a/db/migrations/0169__convert_h1_to_h2.js b/db/migrations/0169__convert_h1_to_h2.js deleted file mode 100644 index f1c2cc4bd..000000000 --- a/db/migrations/0169__convert_h1_to_h2.js +++ /dev/null @@ -1,20 +0,0 @@ -const repository = require('../../src/services/repository'); - -module.exports = () => { - for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) { - try { - let origContent = note.getContent(); - - const newContent = origContent - .replace(/

{ - for (const note of repository.getEntities("SELECT * FROM notes")) { - let position = 0; - - for (const branch of note.getChildBranches()) { - sql.execute(`UPDATE branches SET notePosition = ? WHERE branchId = ?`, [position, branch.branchId]); - - position += 10; - } - } -}; diff --git a/db/migrations/0171__cleanup_options.sql b/db/migrations/0171__cleanup_options.sql deleted file mode 100644 index 9acc7b5ed..000000000 --- a/db/migrations/0171__cleanup_options.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELETE FROM options WHERE name IN ( - 'noteInfoWidget', - 'attributesWidget', - 'linkMapWidget', - 'noteRevisionsWidget', - 'whatLinksHereWidget', - 'codeNotesMimeTypes', - 'similarNotesWidget', - 'editedNotesWidget', - 'calendarWidget', - 'sidebarMinWidth', - 'sidebarWidthPercent', - 'showSidebarInNewTab', - 'hoistedNoteId' -); diff --git a/db/migrations/0173__isErased_in_entity_changes.sql b/db/migrations/0173__isErased_in_entity_changes.sql deleted file mode 100644 index 5125ddcfb..000000000 --- a/db/migrations/0173__isErased_in_entity_changes.sql +++ /dev/null @@ -1,69 +0,0 @@ -CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( - `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `entityName` TEXT NOT NULL, - `entityId` TEXT NOT NULL, - `hash` TEXT NOT NULL, - `sourceId` TEXT NOT NULL, - `isErased` INT NOT NULL, - `utcDateChanged` TEXT NOT NULL, - `isSynced` INTEGER NOT NULL); - -INSERT INTO mig_entity_changes (id, entityName, entityId, hash, sourceId, isSynced, utcDateChanged, isErased) -SELECT id, entityName, entityId, '', sourceId, isSynced, utcChangedDate, 0 FROM entity_changes; - -UPDATE mig_entity_changes SET isErased = COALESCE((SELECT isErased FROM notes WHERE noteId = entityId), 0) WHERE entityName = 'notes'; -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM notes WHERE noteId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'notes'; - -UPDATE mig_entity_changes SET isErased = COALESCE((SELECT isErased FROM notes WHERE noteId = entityId), 0) WHERE entityName = 'note_contents'; - -UPDATE mig_entity_changes SET isErased = COALESCE(( - SELECT isErased - FROM attributes - JOIN notes USING(noteId) - WHERE attributeId = entityId -), 0) WHERE entityName = 'attributes'; -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM attributes WHERE attributeId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'attributes'; - -UPDATE mig_entity_changes SET isErased = COALESCE(( - SELECT isErased - FROM branches - JOIN notes USING(noteId) - WHERE branchId = entityId -), 0) WHERE entityName = 'branches'; -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM branches WHERE branchId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'branches'; - -UPDATE mig_entity_changes SET isErased = COALESCE(( - SELECT isErased - FROM note_revisions - WHERE noteRevisionId = entityId -), 0) WHERE entityName = 'note_revisions'; -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM note_revisions WHERE noteRevisionId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'note_revisions'; - -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateCreated FROM api_tokens WHERE apiTokenId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'api_tokens'; - -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM note_contents WHERE noteId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'note_contents'; - -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM note_revision_contents WHERE noteRevisionId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'note_revision_contents'; - -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM options WHERE name = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'options'; - -UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateCreated FROM recent_notes WHERE noteId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'options'; - -DROP TABLE entity_changes; -ALTER TABLE mig_entity_changes RENAME TO entity_changes; - -CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes" ( - `entityName`, - `entityId` - ); - -DELETE FROM attributes WHERE noteId IN (SELECT noteId FROM notes WHERE isErased = 1); -DELETE FROM branches WHERE noteId IN (SELECT noteId FROM notes WHERE isErased = 1); -DELETE FROM note_contents WHERE noteId IN (SELECT noteId FROM notes WHERE isErased = 1); -DELETE FROM note_revision_contents WHERE noteRevisionId IN ( - SELECT noteRevisionId FROM note_revisions WHERE isErased = 1 -); -DELETE FROM note_revisions WHERE isErased = 1; -DELETE FROM notes WHERE isErased = 1; - -UPDATE entity_changes SET isErased = COALESCE((SELECT isErased FROM entity_changes AS sub WHERE sub.entityId = entity_changes.entityId AND sub.entityName = 'note_revisions'), 0) WHERE entityName = 'note_revision_contents'; diff --git a/db/migrations/0174__move_hash_to_entity_changes.sql b/db/migrations/0174__move_hash_to_entity_changes.sql deleted file mode 100644 index c64c7ad77..000000000 --- a/db/migrations/0174__move_hash_to_entity_changes.sql +++ /dev/null @@ -1,198 +0,0 @@ -CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( - `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `entityName` TEXT NOT NULL, - `entityId` TEXT NOT NULL, - `hash` TEXT NOT NULL, - `isErased` INT NOT NULL, - `sourceId` TEXT NOT NULL, - `isSynced` INTEGER NOT NULL, - `utcDateChanged` TEXT NOT NULL - ); - -INSERT INTO mig_entity_changes (id, entityName, entityId, hash, sourceId, isSynced, isErased, utcDateChanged) - SELECT id, entityName, entityId, '', sourceId, isSynced, isErased, utcDateChanged FROM entity_changes; - -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM api_tokens WHERE apiTokenId = entityId), '') WHERE entityName = 'api_tokens'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM attributes WHERE attributeId = entityId), '') WHERE entityName = 'attributes'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM branches WHERE branchId = entityId), '') WHERE entityName = 'branches'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM notes WHERE noteId = entityId), '') WHERE entityName = 'notes'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM note_contents WHERE noteId = entityId), '') WHERE entityName = 'note_contents'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM note_revisions WHERE noteRevisionId = entityId), '') WHERE entityName = 'note_revisions'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM note_revision_contents WHERE noteRevisionId = entityId), '') WHERE entityName = 'note_revision_contents'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM options WHERE name = entityId), '') WHERE entityName = 'options'; -UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM recent_notes WHERE noteId = entityId), '') WHERE entityName = 'recent_notes'; - -DROP TABLE entity_changes; -ALTER TABLE mig_entity_changes RENAME TO entity_changes; - -CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes" ( - `entityName`, - `entityId` - ); - -CREATE TABLE IF NOT EXISTS "mig_api_tokens" -( - apiTokenId TEXT PRIMARY KEY NOT NULL, - token TEXT NOT NULL, - utcDateCreated TEXT NOT NULL, - isDeleted INT NOT NULL DEFAULT 0); - -INSERT INTO mig_api_tokens (apiTokenId, token, utcDateCreated, isDeleted) -SELECT apiTokenId, token, utcDateCreated, isDeleted FROM api_tokens; - -DROP TABLE api_tokens; -ALTER TABLE mig_api_tokens RENAME TO api_tokens; - -CREATE TABLE IF NOT EXISTS "mig_attributes" -( - attributeId TEXT not null primary key, - noteId TEXT not null, - type TEXT not null, - name TEXT not null, - value TEXT default '' not null, - position INT default 0 not null, - utcDateCreated TEXT not null, - utcDateModified TEXT not null, - isDeleted INT not null, - `deleteId` TEXT DEFAULT NULL, - isInheritable int DEFAULT 0 NULL); - -INSERT INTO mig_attributes (attributeId, noteId, type, name, value, position, utcDateCreated, utcDateModified, isDeleted, deleteId, isInheritable) -SELECT attributeId, noteId, type, name, value, position, utcDateCreated, utcDateModified, isDeleted, deleteId, isInheritable FROM attributes; - -DROP TABLE attributes; -ALTER TABLE mig_attributes RENAME TO attributes; - -CREATE INDEX IDX_attributes_name_value - on attributes (name, value); -CREATE INDEX IDX_attributes_noteId_index - on attributes (noteId); -CREATE INDEX IDX_attributes_value_index - on attributes (value); - -CREATE TABLE IF NOT EXISTS "mig_branches" ( - `branchId` TEXT NOT NULL, - `noteId` TEXT NOT NULL, - `parentNoteId` TEXT NOT NULL, - `notePosition` INTEGER NOT NULL, - `prefix` TEXT, - `isExpanded` INTEGER NOT NULL DEFAULT 0, - `isDeleted` INTEGER NOT NULL DEFAULT 0, - `deleteId` TEXT DEFAULT NULL, - `utcDateModified` TEXT NOT NULL, - utcDateCreated TEXT NOT NULL, - PRIMARY KEY(`branchId`)); - -INSERT INTO mig_branches (branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, deleteId, utcDateModified, utcDateCreated) -SELECT branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, deleteId, utcDateModified, utcDateCreated FROM branches; - -DROP TABLE branches; -ALTER TABLE mig_branches RENAME TO branches; - -CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` (`noteId`,`parentNoteId`); -CREATE INDEX IDX_branches_parentNoteId ON branches (parentNoteId); - -CREATE TABLE IF NOT EXISTS "mig_notes" ( - `noteId` TEXT NOT NULL, - `title` TEXT NOT NULL DEFAULT "note", - `isProtected` INT NOT NULL DEFAULT 0, - `type` TEXT NOT NULL DEFAULT 'text', - `mime` TEXT NOT NULL DEFAULT 'text/html', - `isDeleted` INT NOT NULL DEFAULT 0, - `deleteId` TEXT DEFAULT NULL, - `dateCreated` TEXT NOT NULL, - `dateModified` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`)); - -INSERT INTO mig_notes (noteId, title, isProtected, type, mime, isDeleted, deleteId, dateCreated, dateModified, utcDateCreated, utcDateModified) -SELECT noteId, title, isProtected, type, mime, isDeleted, deleteId, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes; - -DROP TABLE notes; -ALTER TABLE mig_notes RENAME TO notes; - -CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); -CREATE INDEX `IDX_notes_title` ON `notes` (`title`); -CREATE INDEX `IDX_notes_type` ON `notes` (`type`); -CREATE INDEX `IDX_notes_dateCreated` ON `notes` (`dateCreated`); -CREATE INDEX `IDX_notes_dateModified` ON `notes` (`dateModified`); -CREATE INDEX `IDX_notes_utcDateModified` ON `notes` (`utcDateModified`); -CREATE INDEX `IDX_notes_utcDateCreated` ON `notes` (`utcDateCreated`); - -CREATE TABLE IF NOT EXISTS "mig_note_contents" ( - `noteId` TEXT NOT NULL, - `content` TEXT NULL DEFAULT NULL, - `dateModified` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`) -); - -INSERT INTO mig_note_contents (noteId, content, dateModified, utcDateModified) -SELECT noteId, content, dateModified, utcDateModified FROM note_contents; - -DROP TABLE note_contents; -ALTER TABLE mig_note_contents RENAME TO note_contents; - -CREATE TABLE IF NOT EXISTS "mig_note_revisions" (`noteRevisionId` TEXT NOT NULL PRIMARY KEY, - `noteId` TEXT NOT NULL, - type TEXT DEFAULT '' NOT NULL, - mime TEXT DEFAULT '' NOT NULL, - `title` TEXT, - `isProtected` INT NOT NULL DEFAULT 0, - `utcDateLastEdited` TEXT NOT NULL, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - `dateLastEdited` TEXT NOT NULL, - `dateCreated` TEXT NOT NULL); - -INSERT INTO mig_note_revisions (noteRevisionId, noteId, type, mime, title, isProtected, utcDateLastEdited, utcDateCreated, utcDateModified, dateLastEdited, dateCreated) -SELECT noteRevisionId, noteId, type, mime, title, isProtected, utcDateLastEdited, utcDateCreated, utcDateModified, dateLastEdited, dateCreated FROM note_revisions; - -DROP TABLE note_revisions; -ALTER TABLE mig_note_revisions RENAME TO note_revisions; - -CREATE INDEX `IDX_note_revisions_noteId` ON `note_revisions` (`noteId`); -CREATE INDEX `IDX_note_revisions_utcDateCreated` ON `note_revisions` (`utcDateCreated`); -CREATE INDEX `IDX_note_revisions_utcDateLastEdited` ON `note_revisions` (`utcDateLastEdited`); -CREATE INDEX `IDX_note_revisions_dateCreated` ON `note_revisions` (`dateCreated`); -CREATE INDEX `IDX_note_revisions_dateLastEdited` ON `note_revisions` (`dateLastEdited`); - -CREATE TABLE IF NOT EXISTS "mig_note_revision_contents" (`noteRevisionId` TEXT NOT NULL PRIMARY KEY, - `content` TEXT, - `utcDateModified` TEXT NOT NULL); - -INSERT INTO mig_note_revision_contents (noteRevisionId, content, utcDateModified) -SELECT noteRevisionId, content, utcDateModified FROM note_revision_contents; - -DROP TABLE note_revision_contents; -ALTER TABLE mig_note_revision_contents RENAME TO note_revision_contents; - -CREATE TABLE IF NOT EXISTS "mig_options" -( - name TEXT not null PRIMARY KEY, - value TEXT, - isSynced INTEGER default 0 not null, - utcDateCreated TEXT not null, - utcDateModified TEXT NOT NULL -); - -INSERT INTO mig_options (name, value, isSynced, utcDateCreated, utcDateModified) -SELECT name, value, isSynced, utcDateCreated, utcDateModified FROM options; - -DROP TABLE options; -ALTER TABLE mig_options RENAME TO options; - -CREATE TABLE mig_recent_notes -( - noteId TEXT not null primary key, - notePath TEXT not null, - utcDateCreated TEXT not null, - isDeleted INT NOT NULL DEFAULT 0 -); - -INSERT INTO mig_recent_notes (noteId, notePath, utcDateCreated, isDeleted) -SELECT noteId, notePath, utcDateCreated, isDeleted FROM recent_notes; - -DROP TABLE recent_notes; -ALTER TABLE mig_recent_notes RENAME TO recent_notes; diff --git a/db/migrations/0175__rename_eraseNotesAfterTimeInSeconds.sql b/db/migrations/0175__rename_eraseNotesAfterTimeInSeconds.sql deleted file mode 100644 index b84e9e31c..000000000 --- a/db/migrations/0175__rename_eraseNotesAfterTimeInSeconds.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE options SET name = 'eraseEntitiesAfterTimeInSeconds' WHERE name = 'eraseNotesAfterTimeInSeconds'; -UPDATE entity_changes SET entityId = 'eraseEntitiesAfterTimeInSeconds' WHERE entityName = 'options' AND entityId = 'eraseNotesAfterTimeInSeconds'; diff --git a/db/migrations/0176__remove_utcDateCreated_in_attributes.sql b/db/migrations/0176__remove_utcDateCreated_in_attributes.sql deleted file mode 100644 index 1f04e62f2..000000000 --- a/db/migrations/0176__remove_utcDateCreated_in_attributes.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE IF NOT EXISTS "mig_attributes" -( - attributeId TEXT not null primary key, - noteId TEXT not null, - type TEXT not null, - name TEXT not null, - value TEXT default '' not null, - position INT default 0 not null, - utcDateModified TEXT not null, - isDeleted INT not null, - `deleteId` TEXT DEFAULT NULL, - isInheritable int DEFAULT 0 NULL); - -INSERT INTO mig_attributes (attributeId, noteId, type, name, value, position, utcDateModified, isDeleted, deleteId, isInheritable) -SELECT attributeId, noteId, type, name, value, position, utcDateModified, isDeleted, deleteId, isInheritable FROM attributes; - -DROP TABLE attributes; -ALTER TABLE mig_attributes RENAME TO attributes; - -CREATE INDEX IDX_attributes_name_value - on attributes (name, value); -CREATE INDEX IDX_attributes_noteId_index - on attributes (noteId); -CREATE INDEX IDX_attributes_value_index - on attributes (value); diff --git a/db/migrations/0177__cleanup_keyboard_shortcuts.sql b/db/migrations/0177__cleanup_keyboard_shortcuts.sql deleted file mode 100644 index 148d4e61f..000000000 --- a/db/migrations/0177__cleanup_keyboard_shortcuts.sql +++ /dev/null @@ -1,5 +0,0 @@ -DELETE FROM options WHERE name = 'keyboardShortcutsCreateNoteIntoInbox'; -- in case there is already one which shouldn't (except for in-dev documents) -UPDATE options SET name = 'keyboardShortcutsCreateNoteIntoInbox' WHERE name = 'keyboardShortcutsCreateNoteIntoDayNote'; - -DELETE FROM options WHERE name = 'keyboardShortcutsShowAttributes'; -DELETE FROM entity_changes WHERE entityName = 'options' AND entityId = 'keyboardShortcutsShowAttributes'; diff --git a/db/migrations/0178__drop_isDeleted_index.sql b/db/migrations/0178__drop_isDeleted_index.sql deleted file mode 100644 index 1c940b45a..000000000 --- a/db/migrations/0178__drop_isDeleted_index.sql +++ /dev/null @@ -1 +0,0 @@ -DROP INDEX IDX_notes_isDeleted; diff --git a/db/migrations/0179__VACUUM.sql b/db/migrations/0179__VACUUM.sql deleted file mode 100644 index 78434d08a..000000000 --- a/db/migrations/0179__VACUUM.sql +++ /dev/null @@ -1 +0,0 @@ -VACUUM diff --git a/db/migrations/0180__rename_quickSearch_shortcut.sql b/db/migrations/0180__rename_quickSearch_shortcut.sql deleted file mode 100644 index 696881c96..000000000 --- a/db/migrations/0180__rename_quickSearch_shortcut.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE options SET name = 'keyboardShortcutsQuickSearch' WHERE name = 'keyboardShortcutsSearchNotes'; -UPDATE entity_changes SET entityId = 'keyboardShortcutsQuickSearch' WHERE entityId = 'keyboardShortcutsSearchNotes' AND entityName = 'options'; diff --git a/db/migrations/0181__fix_entityChanges_isSynced.sql b/db/migrations/0181__fix_entityChanges_isSynced.sql deleted file mode 100644 index cb80a982f..000000000 --- a/db/migrations/0181__fix_entityChanges_isSynced.sql +++ /dev/null @@ -1,5 +0,0 @@ -UPDATE entity_changes SET isSynced = COALESCE(( - SELECT options.isSynced - FROM options - WHERE options.name = entity_changes.entityId -), 0) WHERE entityName = 'options'; diff --git a/db/migrations/0182__remove_recentChanges_from_entityChanges.sql b/db/migrations/0182__remove_recentChanges_from_entityChanges.sql deleted file mode 100644 index c09b6191a..000000000 --- a/db/migrations/0182__remove_recentChanges_from_entityChanges.sql +++ /dev/null @@ -1,14 +0,0 @@ -DELETE FROM entity_changes WHERE entityName = 'recent_notes'; - -CREATE TABLE IF NOT EXISTS "mig_recent_notes" -( - noteId TEXT not null primary key, - notePath TEXT not null, - utcDateCreated TEXT not null -); - -INSERT INTO mig_recent_notes (noteId, notePath, utcDateCreated) - SELECT noteId, notePath, utcDateCreated FROM recent_notes; - -DROP TABLE recent_notes; -ALTER TABLE mig_recent_notes RENAME TO recent_notes; diff --git a/db/migrations/0183__migrate_saved_search_notes.js b/db/migrations/0183__migrate_saved_search_notes.js deleted file mode 100644 index 4cd7d4968..000000000 --- a/db/migrations/0183__migrate_saved_search_notes.js +++ /dev/null @@ -1,25 +0,0 @@ -const repository = require('../../src/services/repository'); - -module.exports = () => { - for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'search' AND isProtected = 0 AND isDeleted = 0")) { - try { - let origContent = note.getJsonContent(); - - if (!origContent) { - continue; - } - - note.addLabel('searchString', origContent.searchString); - - note.setContent(''); - - note.mime = 'text/plain'; - note.save(); - - console.log(`Migrated search note ${note.noteId}`); - } - catch (e) { - console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`); - } - } -};