removed (112) migrations originating before first public release (0.20 in Sept 2018)

This commit is contained in:
zadam 2021-03-14 20:37:35 +01:00
parent aa8bf0e60a
commit cd3f8a41af
114 changed files with 32 additions and 1485 deletions

View File

@ -1,11 +0,0 @@
DROP TABLE IF EXISTS anchors;
DROP TABLE IF EXISTS attachments;
DROP TABLE IF EXISTS bookmarks;
DROP TABLE IF EXISTS custom_properties;
DROP TABLE IF EXISTS deletions;
DROP TABLE IF EXISTS deletions_attachments;
DROP TABLE IF EXISTS formatting;
DROP TABLE IF EXISTS icons;
DROP TABLE IF EXISTS tags;
DROP TABLE IF EXISTS tags_notes;
DROP TABLE IF EXISTS tasks;

View File

@ -1,3 +0,0 @@
CREATE TABLE notes_mig AS SELECT note_id, note_title, note_text, note_clone_id, date_created, date_modified, encryption FROM notes;
DROP TABLE notes;
ALTER TABLE notes_mig RENAME TO notes;

View File

@ -1 +0,0 @@
ALTER TABLE notes ADD COLUMN is_deleted INTEGER NOT NULL DEFAULT 0

View File

@ -1 +0,0 @@
ALTER TABLE notes_tree ADD COLUMN date_modified INTEGER NOT NULL DEFAULT 0

View File

@ -1 +0,0 @@
DELETE FROM options WHERE opt_name IN ('is_readonly', 'prop_modified', 'doc_title', 'doc_UID', 'format_version', 'flask_secret_key')

View File

@ -1,3 +0,0 @@
CREATE TABLE notes_history_mig AS SELECT id, note_id, note_title, note_text, date_modified AS date_modified_from, date_modified AS date_modified_to FROM notes_history;
DROP TABLE notes_history;
ALTER TABLE notes_history_mig RENAME TO notes_history;

View File

@ -1 +0,0 @@
ALTER TABLE notes_history ADD COLUMN encryption INTEGER DEFAULT 0

View File

@ -1,15 +0,0 @@
CREATE TABLE `notes_history_mig` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`note_id` INT,
`note_title` TEXT,
`note_text` TEXT,
`date_modified_from` INT,
`date_modified_to` INT,
`encryption` INTEGER DEFAULT 0
);
INSERT INTO notes_history (id, note_id, note_title, note_text, date_modified_from, date_modified_to, encryption)
SELECT id, note_id, note_title, note_text, date_modified_from, date_modified_to, encryption FROM notes_history;
DROP TABLE notes_history;
ALTER TABLE notes_history_mig RENAME TO notes_history;

View File

@ -1,41 +0,0 @@
CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (
`note_id`
);
CREATE INDEX `IDX_images_note_id` ON `images` (
`note_id`
);
CREATE INDEX `IDX_links_note_id` ON `links` (
`note_id`
);
CREATE INDEX `IDX_audit_log_note_id` ON `audit_log` (
`note_id`
);
CREATE INDEX `IDX_audit_log_date_modified` ON `audit_log` (
`date_modified`
);
CREATE TABLE `notes_mig` (
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`note_clone_id` TEXT,
`date_created` INT,
`date_modified` INT,
`encryption` INT,
`is_deleted` INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY(`note_id`)
);
INSERT INTO notes_mig (note_id, note_title, note_text, note_clone_id, date_created, date_modified, encryption)
SELECT note_id, note_title, note_text, note_clone_id, date_created, date_modified, encryption FROM notes;
DROP TABLE notes;
ALTER TABLE notes_mig RENAME TO notes;
CREATE INDEX `IDX_notes_is_deleted` ON `notes` (
`is_deleted`
);

View File

@ -1,5 +0,0 @@
ALTER TABLE notes_tree ADD COLUMN is_deleted INTEGER NOT NULL DEFAULT 0;
CREATE INDEX `IDX_notes_tree_is_deleted` ON `notes_tree` (
`is_deleted`
);

View File

@ -1 +0,0 @@
INSERT INTO options (opt_name, opt_value) VALUES ('last_synced', 0)

View File

@ -1,5 +0,0 @@
CREATE UNIQUE INDEX `IDX_notes_history_note_from_to` ON `notes_history` (
`note_id`,
`date_modified_from`,
`date_modified_to`
);

View File

@ -1,3 +0,0 @@
UPDATE options SET opt_name = 'last_synced_pull' WHERE opt_name = 'last_synced';
INSERT INTO options (opt_name, opt_value) VALUES ('last_synced_push', 0);

View File

@ -1,16 +0,0 @@
CREATE TABLE `audit_log_mig` (
`id` TEXT NOT NULL PRIMARY KEY,
`date_modified` INTEGER NOT NULL,
`category` TEXT NOT NULL,
`browser_id` TEXT,
`note_id` TEXT,
`change_from` TEXT,
`change_to` TEXT,
`comment` TEXT
);
INSERT INTO audit_log_mig (id, date_modified, category, browser_id, note_id, change_from, change_to)
SELECT id, date_modified, category, browser_id, note_id, change_from, change_to FROM audit_log;
DROP TABLE audit_log;
ALTER TABLE audit_log_mig RENAME TO audit_log;

View File

@ -1,6 +0,0 @@
UPDATE notes SET note_id = substr(note_id, 0, 22);
UPDATE notes_tree SET note_id = substr(note_id, 0, 22), note_pid = substr(note_pid, 0, 22);
UPDATE notes_history SET note_id = substr(note_id, 0, 22);
UPDATE audit_log SET note_id = substr(note_id, 0, 22);
UPDATE links SET note_id = substr(note_id, 0, 22);
UPDATE images SET note_id = substr(note_id, 0, 22);

View File

@ -1,6 +0,0 @@
UPDATE notes SET note_id = substr(note_id, 0, 13);
UPDATE notes_tree SET note_id = substr(note_id, 0, 13), note_pid = substr(note_pid, 0, 13);
UPDATE notes_history SET note_id = substr(note_id, 0, 13);
UPDATE audit_log SET note_id = substr(note_id, 0, 13);
UPDATE links SET note_id = substr(note_id, 0, 13);
UPDATE images SET note_id = substr(note_id, 0, 13);

View File

@ -1 +0,0 @@
INSERT INTO options (opt_name, opt_value) VALUES ('document_id', '');

View File

@ -1 +0,0 @@
INSERT INTO options (opt_name, opt_value) VALUES ('document_secret', '');

View File

@ -1 +0,0 @@
ALTER TABLE options ADD COLUMN date_modified INTEGER NOT NULL DEFAULT 0

View File

@ -1,15 +0,0 @@
CREATE TABLE `sync` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entity_name` TEXT NOT NULL,
`entity_id` TEXT NOT NULL,
`sync_date` INTEGER NOT NULL
);
CREATE UNIQUE INDEX `IDX_sync_entity_name_id` ON `sync` (
`entity_name`,
`entity_id`
);
CREATE INDEX `IDX_sync_sync_date` ON `sync` (
`sync_date`
);

View File

@ -1 +0,0 @@
ALTER TABLE sync ADD COLUMN source_id TEXT

View File

@ -1,7 +0,0 @@
ALTER TABLE notes_history ADD COLUMN note_history_id TEXT;
UPDATE notes_history SET note_history_id = id;
CREATE UNIQUE INDEX `IDX_note_history_note_history_id` ON `notes_history` (
`note_history_id`
);

View File

@ -1,27 +0,0 @@
CREATE TABLE `notes_history_mig` (
`note_history_id` TEXT NOT NULL PRIMARY KEY,
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`encryption` INT,
`date_modified_from` INT,
`date_modified_to` INT
);
INSERT INTO notes_history_mig (note_history_id, note_id, note_title, note_text, encryption, date_modified_from, date_modified_to)
SELECT note_history_id, note_id, note_title, note_text, encryption, date_modified_from, date_modified_to FROM notes_history;
DROP TABLE notes_history;
ALTER TABLE notes_history_mig RENAME TO notes_history;
CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (
`note_id`
);
CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` (
`date_modified_from`
);
CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` (
`date_modified_to`
);

View File

@ -1,11 +0,0 @@
CREATE TABLE `options_mig` (
`opt_name` TEXT NOT NULL PRIMARY KEY,
`opt_value` TEXT,
`date_modified` INT
);
INSERT INTO options_mig (opt_name, opt_value, date_modified)
SELECT opt_name, opt_value, date_modified FROM options;
DROP TABLE options;
ALTER TABLE options_mig RENAME TO options;

View File

@ -1,10 +0,0 @@
CREATE TABLE `event_log` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`note_id` TEXT,
`comment` TEXT,
`date_added` INTEGER NOT NULL
);
CREATE INDEX `IDX_event_log_date_added` ON `event_log` (
`date_added`
);

View File

@ -1,4 +0,0 @@
CREATE TABLE `recent_notes` (
`note_id` TEXT NOT NULL PRIMARY KEY,
`date_accessed` INTEGER NOT NULL
);

View File

@ -1 +0,0 @@
ALTER TABLE recent_notes ADD COLUMN is_deleted INT;

View File

@ -1,52 +0,0 @@
UPDATE audit_log SET category = 'PROTECTED' WHERE category = 'ENCRYPTION';
DELETE FROM notes WHERE note_clone_id IS NOT NULL AND note_clone_id != '';
CREATE TABLE `notes_mig` (
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`date_created` INT,
`date_modified` INT,
`is_protected` INT NOT NULL DEFAULT 0,
`is_deleted` INT NOT NULL DEFAULT 0,
PRIMARY KEY(`note_id`)
);
INSERT INTO notes_mig (note_id, note_title, note_text, date_created, date_modified, is_protected, is_deleted)
SELECT note_id, note_title, note_text, date_created, date_modified, encryption, is_deleted FROM notes;
DROP TABLE notes;
ALTER TABLE notes_mig RENAME TO notes;
CREATE INDEX `IDX_notes_is_deleted` ON `notes` (
`is_deleted`
);
CREATE TABLE `notes_history_mig` (
`note_history_id` TEXT NOT NULL PRIMARY KEY,
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`is_protected` INT,
`date_modified_from` INT,
`date_modified_to` INT
);
INSERT INTO notes_history_mig (note_history_id, note_id, note_title, note_text, is_protected, date_modified_from, date_modified_to)
SELECT note_history_id, note_id, note_title, note_text, encryption, date_modified_from, date_modified_to FROM notes_history;
DROP TABLE notes_history;
ALTER TABLE notes_history_mig RENAME TO notes_history;
CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (
`note_id`
);
CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` (
`date_modified_from`
);
CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` (
`date_modified_to`
);

View File

@ -1 +0,0 @@
UPDATE options SET opt_name = 'protected_session_timeout' WHERE opt_name = 'encryption_session_timeout';

View File

@ -1 +0,0 @@
module.exports = async () => console.log("heeeelllooo!!!");

View File

@ -1,44 +0,0 @@
const sql = require('../services/sql');
const data_encryption = require('../services/data_encryption');
const password_encryption = require('../services/password_encryption');
const readline = require('readline');
const cl = readline.createInterface(process.stdin, process.stdout);
function question(q) {
return new Promise( (res, rej) => {
cl.question( q, answer => {
res(answer);
})
});
}
module.exports = async () => {
const password = await question("Enter password: ");
const dataKey = await password_encryption.getDecryptedDataKey(password);
const protectedNotes = await sql.getRows("SELECT * FROM notes WHERE is_protected = 1");
for (const note of protectedNotes) {
const decryptedTitle = data_encryption.decrypt(dataKey, note.note_title);
note.note_title = data_encryption.encrypt(dataKey, "0" + note.note_id, decryptedTitle);
const decryptedText = data_encryption.decrypt(dataKey, note.note_text);
note.note_text = data_encryption.encrypt(dataKey, "1" + note.note_id, decryptedText);
await sql.execute("UPDATE notes SET note_title = ?, note_text = ? WHERE note_id = ?", [note.note_title, note.note_text, note.note_id]);
}
const protectedNotesHistory = await sql.getRows("SELECT * FROM notes_history WHERE is_protected = 1");
for (const noteHistory of protectedNotesHistory) {
const decryptedTitle = data_encryption.decrypt(dataKey, noteHistory.note_title);
noteHistory.note_title = data_encryption.encrypt(dataKey, "0" + noteHistory.note_history_id, decryptedTitle);
const decryptedText = data_encryption.decrypt(dataKey, noteHistory.note_text);
noteHistory.note_text = data_encryption.encrypt(dataKey, "1" + noteHistory.note_history_id, decryptedText);
await sql.execute("UPDATE notes SET note_title = ?, note_text = ? WHERE note_id = ?", [noteHistory.note_title, noteHistory.note_text, noteHistory.note_history_id]);
}
};

View File

@ -1 +0,0 @@
INSERT INTO options (opt_name, opt_value) VALUES ('encrypted_data_key_iv', '')

View File

@ -1,25 +0,0 @@
const password_encryption = require('../services/password_encryption');
const readline = require('readline');
const cl = readline.createInterface(process.stdin, process.stdout);
function question(q) {
return new Promise( (res, rej) => {
cl.question( q, answer => {
res(answer);
})
});
}
module.exports = async () => {
const password = await question("Enter password: ");
let dataKey = await password_encryption.getDecryptedDataKey(password);
console.log("Original data key: ", dataKey);
dataKey = dataKey.slice(0, 16);
console.log("Trimmed data key: ", dataKey);
await password_encryption.setDataKey(password, dataKey);
};

View File

@ -1,5 +0,0 @@
CREATE TABLE `source_ids` (
`source_id` TEXT NOT NULL,
`date_created` INTEGER NOT NULL,
PRIMARY KEY(`source_id`)
);

View File

@ -1 +0,0 @@
UPDATE notes_tree SET note_pid = 'root' WHERE note_pid = ''

View File

@ -1 +0,0 @@
DELETE FROM sync;

View File

@ -1,21 +0,0 @@
CREATE TABLE [notes_tree_mig] (
[note_tree_id] VARCHAR(30) PRIMARY KEY NOT NULL,
[note_id] VARCHAR(30) UNIQUE NOT NULL,
[note_pid] VARCHAR(30) NOT NULL,
[note_pos] INTEGER NOT NULL,
[is_expanded] BOOLEAN NULL ,
date_modified INTEGER NOT NULL DEFAULT 0,
is_deleted INTEGER NOT NULL DEFAULT 0
);
INSERT INTO notes_tree_mig (note_tree_id, note_id, note_pid, note_pos, is_expanded, date_modified, is_deleted)
SELECT 'TT' || SUBSTR(note_id, 3), note_id, note_pid, note_pos, is_expanded, date_modified, is_deleted FROM notes_tree;
UPDATE notes_tree_mig SET note_pid = 'TT' || SUBSTR(note_pid, 3) WHERE note_pid != 'root';
DROP TABLE notes_tree;
ALTER TABLE notes_tree_mig RENAME TO notes_tree;
CREATE INDEX `IDX_notes_tree_note_id` ON `notes_tree` (
`note_tree_id`
);

View File

@ -1 +0,0 @@
UPDATE options SET opt_name = 'start_note_tree_id' WHERE opt_name = 'start_node';

View File

@ -1,7 +0,0 @@
DROP TABLE recent_notes;
CREATE TABLE `recent_notes` (
`note_tree_id` TEXT NOT NULL PRIMARY KEY,
`date_accessed` INTEGER NOT NULL ,
is_deleted INT
);

View File

@ -1,6 +0,0 @@
UPDATE
notes_tree
SET
note_pid = (SELECT parent.note_id FROM notes_tree parent WHERE notes_tree.note_pid = parent.note_tree_id)
WHERE
note_pid != 'root'

View File

@ -1,7 +0,0 @@
DROP TABLE recent_notes;
CREATE TABLE `recent_notes` (
`note_path` TEXT NOT NULL PRIMARY KEY,
`date_accessed` INTEGER NOT NULL ,
is_deleted INT
);

View File

@ -1,24 +0,0 @@
CREATE TABLE "notes_tree_mig" (
[note_tree_id] VARCHAR(30) PRIMARY KEY NOT NULL,
[note_id] VARCHAR(30) NOT NULL,
[note_pid] VARCHAR(30) NOT NULL,
[note_pos] INTEGER NOT NULL,
[is_expanded] BOOLEAN NULL ,
date_modified INTEGER NOT NULL DEFAULT 0,
is_deleted INTEGER NOT NULL DEFAULT 0
);
INSERT INTO notes_tree_mig (note_tree_id, note_id, note_pid, note_pos, is_expanded, date_modified, is_deleted)
SELECT note_tree_id, note_id, note_pid, note_pos, is_expanded, date_modified, is_deleted FROM notes_tree;
DROP TABLE notes_tree;
ALTER TABLE notes_tree_mig RENAME TO notes_tree;
CREATE INDEX `IDX_notes_tree_note_tree_id` ON `notes_tree` (
`note_tree_id`
);
CREATE INDEX `IDX_notes_tree_note_id_note_pid` ON `notes_tree` (
`note_id`,
`note_pid`
);

View File

@ -1,3 +0,0 @@
DELETE FROM sync;
UPDATE options SET opt_value = 0 WHERE opt_name IN ('last_synced_push', 'last_synced_pull');

View File

@ -1 +0,0 @@
DROP TABLE audit_log;

View File

@ -1 +0,0 @@
ALTER TABLE notes_tree ADD COLUMN `prefix` TEXT

View File

@ -1,2 +0,0 @@
DROP TABLE IF EXISTS links;
DROP TABLE IF EXISTS images;

View File

@ -1 +0,0 @@
SELECT 1;

View File

@ -1,10 +0,0 @@
DROP TABLE recent_notes;
CREATE TABLE `recent_notes` (
'note_tree_id'TEXT NOT NULL PRIMARY KEY,
`note_path` TEXT NOT NULL,
`date_accessed` INTEGER NOT NULL ,
is_deleted INT
);
DELETE FROM sync WHERE entity_name = 'recent_notes';

View File

@ -1 +0,0 @@
UPDATE options SET opt_name = 'start_note_path' WHERE opt_name = 'start_note_tree_id';

View File

@ -1,156 +0,0 @@
DROP TABLE migrations;
-- Sync
CREATE TABLE `sync_mig` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entity_name` TEXT NOT NULL,
`entity_id` TEXT NOT NULL,
`source_id` TEXT NOT NULL,
`sync_date` TEXT NOT NULL);
INSERT INTO sync_mig (id, entity_name, entity_id, source_id, sync_date)
SELECT id, entity_name, entity_id, source_id, strftime('%Y-%m-%dT%H:%M:%S.000Z', sync_date, 'unixepoch') FROM sync;
DROP TABLE sync;
ALTER TABLE sync_mig RENAME TO sync;
CREATE UNIQUE INDEX `IDX_sync_entity_name_id` ON `sync` (
`entity_name`,
`entity_id`
);
CREATE INDEX `IDX_sync_sync_date` ON `sync` (
`sync_date`
);
-- Options
UPDATE options SET opt_value = strftime('%Y-%m-%dT%H:%M:%S.000Z', opt_value, 'unixepoch') WHERE opt_name IN ('last_backup_date');
UPDATE options SET date_modified = strftime('%Y-%m-%dT%H:%M:%S.000Z', date_modified, 'unixepoch');
-- Event log
CREATE TABLE `event_log_mig` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`note_id` TEXT,
`comment` TEXT,
`date_added` TEXT NOT NULL
);
INSERT INTO event_log_mig (id, note_id, comment, date_added)
SELECT id, note_id, comment, strftime('%Y-%m-%dT%H:%M:%S.000Z', date_added, 'unixepoch') FROM event_log;
DROP TABLE event_log;
ALTER TABLE event_log_mig RENAME TO event_log;
CREATE INDEX `IDX_event_log_date_added` ON `event_log` (
`date_added`
);
-- Notes
CREATE TABLE IF NOT EXISTS "notes_mig" (
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`is_protected` INT NOT NULL DEFAULT 0,
`is_deleted` INT NOT NULL DEFAULT 0,
`date_created` TEXT NOT NULL,
`date_modified` TEXT NOT NULL,
PRIMARY KEY(`note_id`)
);
INSERT INTO notes_mig (note_id, note_title, note_text, is_protected, is_deleted, date_created, date_modified)
SELECT note_id, note_title, note_text, is_protected, is_deleted,
strftime('%Y-%m-%dT%H:%M:%S.000Z', date_created, 'unixepoch'),
strftime('%Y-%m-%dT%H:%M:%S.000Z', date_modified, 'unixepoch')
FROM notes;
DROP TABLE notes;
ALTER TABLE notes_mig RENAME TO notes;
CREATE INDEX `IDX_notes_is_deleted` ON `notes` (
`is_deleted`
);
-- note history
CREATE TABLE IF NOT EXISTS "notes_history_mig" (
`note_history_id` TEXT NOT NULL PRIMARY KEY,
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`is_protected` INT NOT NULL DEFAULT 0,
`date_modified_from` TEXT NOT NULL,
`date_modified_to` TEXT NOT NULL
);
INSERT INTO notes_history_mig (note_history_id, note_id, note_title, note_text, is_protected, date_modified_from, date_modified_to)
SELECT note_history_id, note_id, note_title, note_text, is_protected,
strftime('%Y-%m-%dT%H:%M:%S.000Z', date_modified_from, 'unixepoch'),
strftime('%Y-%m-%dT%H:%M:%S.000Z', date_modified_to, 'unixepoch')
FROM notes_history;
DROP TABLE notes_history;
ALTER TABLE notes_history_mig RENAME TO notes_history;
CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (
`note_id`
);
CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` (
`date_modified_from`
);
CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` (
`date_modified_to`
);
-- Source IDs
DROP TABLE source_ids;
CREATE TABLE `source_ids` (
`source_id` TEXT NOT NULL,
`date_created` TEXT NOT NULL,
PRIMARY KEY(`source_id`)
);
-- Recent notes
DROP TABLE recent_notes;
CREATE TABLE `recent_notes` (
`note_tree_id` TEXT NOT NULL PRIMARY KEY,
`note_path` TEXT NOT NULL,
`date_accessed` TEXT NOT NULL,
is_deleted INT
);
-- Notes tree
CREATE TABLE IF NOT EXISTS "notes_tree_mig" (
`note_tree_id` TEXT NOT NULL,
`note_id` TEXT NOT NULL,
`note_pid` TEXT NOT NULL,
`note_pos` INTEGER NOT NULL,
`prefix` TEXT,
`is_expanded` BOOLEAN,
`is_deleted` INTEGER NOT NULL DEFAULT 0,
`date_modified` TEXT NOT NULL,
PRIMARY KEY(`note_tree_id`)
);
INSERT INTO notes_tree_mig (note_tree_id, note_id, note_pid, note_pos, prefix, is_expanded, is_deleted, date_modified)
SELECT note_tree_id, note_id, note_pid, note_pos, prefix, is_expanded, is_deleted,
strftime('%Y-%m-%dT%H:%M:%S.000Z', date_modified, 'unixepoch')
FROM notes_tree;
DROP TABLE notes_tree;
ALTER TABLE notes_tree_mig RENAME TO notes_tree;
CREATE INDEX `IDX_notes_tree_note_tree_id` ON `notes_tree` (
`note_tree_id`
);
CREATE INDEX `IDX_notes_tree_note_id_note_pid` ON `notes_tree` (
`note_id`,
`note_pid`
);

View File

@ -1,5 +0,0 @@
DROP index IDX_notes_tree_note_tree_id;
CREATE INDEX `IDX_notes_tree_note_id` ON `notes_tree` (
`note_id`
);

View File

@ -1,8 +0,0 @@
INSERT OR IGNORE INTO sync (entity_name, entity_id, sync_date, source_id)
SELECT 'notes', note_id, strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'), 'IMPORT' FROM notes;
INSERT OR IGNORE INTO sync (entity_name, entity_id, sync_date, source_id)
SELECT 'notes_tree', note_tree_id, strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'), 'IMPORT' FROM notes_tree;
INSERT OR IGNORE INTO sync (entity_name, entity_id, sync_date, source_id)
SELECT 'notes_history', note_history_id, strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'), 'IMPORT' FROM notes_history;

View File

@ -1,18 +0,0 @@
delete from notes where note_id in ('FfZylYxt','HqzAEsR2fFEZ','KgTQDh67+1Mh','TKMbAYl0AFyQ','W+bGM185c6gw',
'YXBdhv4dYKMy','aF4/6p1zTpIS','nsLnrrDktl/s','wkhFImoPuxky');
delete from notes_tree where note_tree_id in ('TTy5N2y2S6JP','TTkL3rWDexpp','TTEhtomZekUk','TTvP7zW01zwg','TTuYmMTZyKRt'
,'TToaClamxbBF','TTKvNCe5X2dj','TTE7jFx5A0zW','TTc79bscyrHX','TTcw8ZyDy2Cc','TTdFzAOWA9hZ','TTUyVLqyIvVg','TTy85NKSBDyO'
,'TTCyuireAWBv','TTDpVyuzbj1a','TTYznrYvAeIs','TTocvv15VMyu','TTjtxQkBT5vj','TToyyRzbBF0T','TTFt8NE9vSyZ','TTfzFZOuuDqv'
,'TT2e2oUYcxG6','TToXselUpPAy','TTEM68gGukg0','TTkZxxwtUOzW','TTAZNxBtgmmh','TTK1YErdBE3x','TTzjKiEf54o6','TTPWd5Ou1xET'
,'TTxQtjf22rTL','TTJAGaI4c89V','TTUQmsxSTdV3','TTGAOf5Lvr6b','TTECSDRN4ZPW','TTZZXLiGNWv4','TTxSLphulRct','TT8vld7x0qWF'
,'TTuuxXnv2Kpw','TT3RkLZ9AI6t','TTuEbI4Cj3qC','TT4CXXRyWRqm','TTQCuFgnMqxX','TTxnDEMz1bd4','TTMOnqhBesjs','TTHblx55gRHN'
,'TTMHW8HIGCjR','TTxzg3qqyLjw','TTluvD7yS8Rv','TT88qK2j3ggk','TTF7oHhS5ANF','TTOH275JiUSy','TToIt2dQ5tYH','TTBPgixQgbAq'
,'TTeN46707CJl','TTDb3GC2y6nN','TTlIXFwpICko','TTE6M9AxLh2U','TTjqhB8zXjD6','TT9NPeLg4FjK','TTj12jDX7TM3','TTPRjf7EdvDX'
,'TTBnu09pxOmn','TTZxyAkJQ9Cf','TTlvqeof2IBS','TT5R5xtIqRQf','TTiiD6hFjlVH','TTNVjGHSqNgo','TTrORSHCsAVQ','TT5Ei5fngqkv'
,'TTQ4hdpcIX3C','TTQgxq4CoiHU','TTJayLjI6BSE','TTYyraNy0CVT','TTnAJ3AK3wHz','TTJwKcgs1s0X','TT4FiatgbLEs','TTEdp5Zx1n5F');
update notes_tree set is_deleted = 1 where note_tree_id in ('TTiaU9xqnrca','TTQAy9c1vDId','TTHXWBJB2Y24','TTDV8DUK2IZA'
,'TTI5JHODZYV5','TTBEZ8TMSJV4','TT1MDWZXE8ZI','TTJV7ZOA8907','TTUGE6N99QSO','TTN0OS17T0KM');
delete from notes_history where note_history_id in ('KHAp5viTrrOfugzQ', 'xmhaS76piZn0QGzn', '25aL96ke8xmud9Bt');

View File

@ -1,3 +0,0 @@
DELETE FROM notes_tree WHERE note_tree_id IN ('cb94QGgnCwOD', 'c3FWKhcVYyaQ');
DELETE FROM notes_history WHERE note_history_id IN ('cdUD6ycs3l9h', 'OW4uh0HLtXaw');

View File

@ -1 +0,0 @@
UPDATE options SET opt_value = (SELECT MAX(id) FROM sync) WHERE opt_name = 'last_synced_push';

View File

@ -1,13 +0,0 @@
DELETE FROM recent_notes;
DELETE FROM sync;
INSERT OR IGNORE INTO sync (entity_name, entity_id, sync_date, source_id)
SELECT 'notes', note_id, strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'), 'IMPORT' FROM notes;
INSERT OR IGNORE INTO sync (entity_name, entity_id, sync_date, source_id)
SELECT 'notes_tree', note_tree_id, strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'), 'IMPORT' FROM notes_tree;
INSERT OR IGNORE INTO sync (entity_name, entity_id, sync_date, source_id)
SELECT 'notes_history', note_history_id, strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'), 'IMPORT' FROM notes_history;
UPDATE options SET opt_value = (SELECT MAX(id) FROM sync) WHERE opt_name IN ('last_synced_push', 'last_synced_pull');

View File

@ -1,101 +0,0 @@
INSERT INTO notes (note_id, note_title, note_text, date_created, date_modified)
VALUES ('root', 'root', 'root', strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'), strftime('%Y-%m-%dT%H:%M:%S.000Z', 'now'));
CREATE TABLE IF NOT EXISTS "notes_mig" (
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`is_protected` INT NOT NULL DEFAULT 0,
`is_deleted` INT NOT NULL DEFAULT 0,
`date_created` TEXT NOT NULL,
`date_modified` TEXT NOT NULL,
PRIMARY KEY(`note_id`)
);
INSERT INTO notes_mig (note_id, note_title, note_text, is_protected, is_deleted, date_created, date_modified)
SELECT note_id, note_title, note_text, is_protected, is_deleted, date_created, date_modified FROM notes;
DROP TABLE notes;
ALTER TABLE notes_mig RENAME TO notes;
CREATE INDEX `IDX_notes_is_deleted` ON `notes` (
`is_deleted`
);
CREATE TABLE IF NOT EXISTS "notes_tree_mig" (
`note_tree_id` TEXT NOT NULL,
`note_id` TEXT NOT NULL,
`parent_note_id` TEXT NOT NULL,
`note_position` INTEGER NOT NULL,
`prefix` TEXT,
`is_expanded` BOOLEAN,
`is_deleted` INTEGER NOT NULL DEFAULT 0,
`date_modified` TEXT NOT NULL,
FOREIGN KEY(note_id) REFERENCES notes(note_id),
FOREIGN KEY(parent_note_id) REFERENCES notes(note_id),
PRIMARY KEY(`note_tree_id`)
);
INSERT INTO notes_tree_mig (note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified)
SELECT note_tree_id, note_id, note_pid, note_pos, prefix, is_expanded, is_deleted, date_modified FROM notes_tree;
DROP TABLE notes_tree;
ALTER TABLE notes_tree_mig RENAME TO notes_tree;
CREATE INDEX `IDX_notes_tree_note_tree_id` ON `notes_tree` (
`note_tree_id`
);
CREATE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (
`note_id`,
`parent_note_id`
);
CREATE INDEX `IDX_notes_tree_note_id` ON `notes_tree` (
`note_id`
);
CREATE TABLE IF NOT EXISTS "notes_history_mig" (
`note_history_id` TEXT NOT NULL PRIMARY KEY,
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`is_protected` INT NOT NULL DEFAULT 0,
`date_modified_from` TEXT NOT NULL,
`date_modified_to` TEXT NOT NULL,
FOREIGN KEY(note_id) REFERENCES notes(note_id)
);
INSERT INTO notes_history_mig (note_history_id, note_id, note_title, note_text, is_protected, date_modified_from, date_modified_to)
SELECT note_history_id, note_id, note_title, note_text, is_protected, date_modified_from, date_modified_to FROM notes_history;
DROP TABLE notes_history;
ALTER TABLE notes_history_mig RENAME TO notes_history;
CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (
`note_id`
);
CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` (
`date_modified_from`
);
CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` (
`date_modified_to`
);
DROP TABLE recent_notes;
CREATE TABLE `recent_notes` (
`note_tree_id` TEXT NOT NULL PRIMARY KEY,
`note_path` TEXT NOT NULL,
`date_accessed` TEXT NOT NULL,
is_deleted INT,
FOREIGN KEY(note_tree_id) REFERENCES notes_tree(note_tree_id)
);
DROP TABLE event_log;
CREATE TABLE `event_log` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`note_id` TEXT,
`comment` TEXT,
`date_added` TEXT NOT NULL,
FOREIGN KEY(note_id) REFERENCES notes(note_id)
);

View File

@ -1,29 +0,0 @@
CREATE TABLE IF NOT EXISTS "notes_tree_mig" (
`note_tree_id` TEXT NOT NULL,
`note_id` TEXT NOT NULL,
`parent_note_id` TEXT NOT NULL,
`note_position` INTEGER NOT NULL,
`prefix` TEXT,
`is_expanded` BOOLEAN,
`is_deleted` INTEGER NOT NULL DEFAULT 0,
`date_modified` TEXT NOT NULL,
FOREIGN KEY(note_id) REFERENCES notes(note_id),
PRIMARY KEY(`note_tree_id`)
);
INSERT INTO notes_tree_mig (note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified)
SELECT note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified FROM notes_tree;
DROP TABLE notes_tree;
ALTER TABLE notes_tree_mig RENAME TO notes_tree;
CREATE INDEX `IDX_notes_tree_note_tree_id` ON `notes_tree` (
`note_tree_id`
);
CREATE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (
`note_id`,
`parent_note_id`
);
CREATE INDEX `IDX_notes_tree_note_id` ON `notes_tree` (
`note_id`
);

View File

@ -1,28 +0,0 @@
CREATE TABLE IF NOT EXISTS "notes_tree_mig" (
`note_tree_id` TEXT NOT NULL,
`note_id` TEXT NOT NULL,
`parent_note_id` TEXT NOT NULL,
`note_position` INTEGER NOT NULL,
`prefix` TEXT,
`is_expanded` BOOLEAN,
`is_deleted` INTEGER NOT NULL DEFAULT 0,
`date_modified` TEXT NOT NULL,
PRIMARY KEY(`note_tree_id`)
);
INSERT INTO notes_tree_mig (note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified)
SELECT note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified FROM notes_tree;
DROP TABLE notes_tree;
ALTER TABLE notes_tree_mig RENAME TO notes_tree;
CREATE INDEX `IDX_notes_tree_note_tree_id` ON `notes_tree` (
`note_tree_id`
);
CREATE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (
`note_id`,
`parent_note_id`
);
CREATE INDEX `IDX_notes_tree_note_id` ON `notes_tree` (
`note_id`
);

View File

@ -1,34 +0,0 @@
CREATE TABLE IF NOT EXISTS "notes_history_mig" (
`note_history_id` TEXT NOT NULL PRIMARY KEY,
`note_id` TEXT NOT NULL,
`note_title` TEXT,
`note_text` TEXT,
`is_protected` INT NOT NULL DEFAULT 0,
`date_modified_from` TEXT NOT NULL,
`date_modified_to` TEXT NOT NULL
);
INSERT INTO notes_history_mig (note_history_id, note_id, note_title, note_text, is_protected, date_modified_from, date_modified_to)
SELECT note_history_id, note_id, note_title, note_text, is_protected, date_modified_from, date_modified_to FROM notes_history;
DROP TABLE notes_history;
ALTER TABLE notes_history_mig RENAME TO notes_history;
CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (
`note_id`
);
CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` (
`date_modified_from`
);
CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` (
`date_modified_to`
);
DROP TABLE recent_notes;
CREATE TABLE `recent_notes` (
`note_tree_id` TEXT NOT NULL PRIMARY KEY,
`note_path` TEXT NOT NULL,
`date_accessed` TEXT NOT NULL,
is_deleted INT
);

View File

@ -1,6 +0,0 @@
DROP INDEX IDX_notes_tree_note_id_parent_note_id;
CREATE UNIQUE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (
`note_id`,
`parent_note_id`
);

View File

@ -1,9 +0,0 @@
DROP INDEX IDX_notes_tree_note_id_parent_note_id;
CREATE INDEX `IDX_notes_tree_note_id_parent_note_id` ON `notes_tree` (
`note_id`,
`parent_note_id`
);
-- dropping this as it's just duplicate of primary key
DROP INDEX IDX_notes_tree_note_tree_id;

View File

@ -1,11 +0,0 @@
CREATE TABLE images
(
image_id TEXT PRIMARY KEY NOT NULL,
format TEXT NOT NULL,
checksum TEXT NOT NULL,
name TEXT NOT NULL,
data BLOB,
is_deleted INT NOT NULL DEFAULT 0,
date_modified TEXT NOT NULL,
date_created TEXT NOT NULL
);

View File

@ -1,16 +0,0 @@
DROP TABLE images;
CREATE TABLE images
(
image_id TEXT PRIMARY KEY NOT NULL,
note_id TEXT NOT NULL,
format TEXT NOT NULL,
checksum TEXT NOT NULL,
name TEXT NOT NULL,
data BLOB,
is_deleted INT NOT NULL DEFAULT 0,
date_modified TEXT NOT NULL,
date_created TEXT NOT NULL
);
CREATE INDEX images_note_id_index ON images (note_id);

View File

@ -1,27 +0,0 @@
DROP TABLE images;
CREATE TABLE images
(
image_id TEXT PRIMARY KEY NOT NULL,
format TEXT NOT NULL,
checksum TEXT NOT NULL,
name TEXT NOT NULL,
data BLOB,
is_deleted INT NOT NULL DEFAULT 0,
date_modified TEXT NOT NULL,
date_created TEXT NOT NULL
);
CREATE TABLE notes_image
(
note_image_id TEXT PRIMARY KEY NOT NULL,
note_id TEXT NOT NULL,
image_id TEXT NOT NULL,
is_deleted INT NOT NULL DEFAULT 0,
date_modified TEXT NOT NULL,
date_created TEXT NOT NULL
);
CREATE INDEX notes_image_note_id_index ON notes_image (note_id);
CREATE INDEX notes_image_image_id_index ON notes_image (image_id);
CREATE INDEX notes_image_note_id_image_id_index ON notes_image (note_id, image_id);

View File

@ -1,12 +0,0 @@
CREATE TABLE attributes
(
attribute_id TEXT PRIMARY KEY NOT NULL,
note_id TEXT NOT NULL,
name TEXT NOT NULL,
value TEXT,
date_created TEXT NOT NULL,
date_modified TEXT NOT NULL
);
CREATE INDEX attributes_note_id_index ON attributes (note_id);
CREATE UNIQUE INDEX attributes_note_id_name_index ON attributes (note_id, name);

View File

@ -1,5 +0,0 @@
ALTER TABLE options ADD COLUMN is_synced INTEGER NOT NULL DEFAULT 0;
UPDATE options SET is_synced = 1 WHERE opt_name IN ('username', 'password_verification_hash', 'password_verification_salt',
'password_derived_key_salt', 'encrypted_data_key', 'encrypted_data_key_iv',
'protected_session_timeout', 'history_snapshot_time_interval');

View File

@ -1 +0,0 @@
ALTER TABLE notes ADD COLUMN type TEXT NOT NULL DEFAULT 'text';

View File

@ -1 +0,0 @@
ALTER TABLE notes ADD COLUMN mime TEXT NOT NULL DEFAULT 'text/html';

View File

@ -1,207 +0,0 @@
CREATE TABLE "options_mig" (
`name` TEXT NOT NULL PRIMARY KEY,
`value` TEXT,
`dateModified` INT,
isSynced INTEGER NOT NULL DEFAULT 0);
INSERT INTO options_mig (name, value, dateModified, isSynced)
SELECT opt_name, opt_value, date_modified, is_synced FROM options;
DROP TABLE options;
ALTER TABLE options_mig RENAME TO options;
CREATE TABLE "sync_mig" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entityName` TEXT NOT NULL,
`entityId` TEXT NOT NULL,
`sourceId` TEXT NOT NULL,
`syncDate` TEXT NOT NULL);
INSERT INTO sync_mig (id, entityName, entityId, sourceId, syncDate)
SELECT id, entity_name, entity_id, source_id, sync_date 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_syncDate` ON `sync` (
`syncDate`
);
CREATE TABLE `source_ids_mig` (
`sourceId` TEXT NOT NULL,
`dateCreated` TEXT NOT NULL,
PRIMARY KEY(`sourceId`)
);
INSERT INTO source_ids_mig (sourceId, dateCreated)
SELECT source_id, date_created FROM source_ids;
DROP TABLE source_ids;
ALTER TABLE source_ids_mig RENAME TO source_ids;
CREATE TABLE "notes_mig" (
`noteId` TEXT NOT NULL,
`title` TEXT,
`content` TEXT,
`isProtected` INT NOT NULL DEFAULT 0,
`isDeleted` INT NOT NULL DEFAULT 0,
`dateCreated` TEXT NOT NULL,
`dateModified` TEXT NOT NULL,
type TEXT NOT NULL DEFAULT 'text',
mime TEXT NOT NULL DEFAULT 'text/html',
PRIMARY KEY(`noteId`)
);
INSERT INTO notes_mig (noteId, title, content, isProtected, isDeleted, dateCreated, dateModified, type, mime)
SELECT note_id, note_title, note_text, is_protected, is_deleted, date_created, date_modified, type, mime FROM notes;
DROP TABLE notes;
ALTER TABLE notes_mig RENAME TO notes;
CREATE INDEX `IDX_notes_isDeleted` ON `notes` (
`isDeleted`
);
CREATE TABLE `event_log_mig` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`noteId` TEXT,
`comment` TEXT,
`dateAdded` TEXT NOT NULL,
FOREIGN KEY(noteId) REFERENCES notes(noteId)
);
INSERT INTO event_log_mig (id, noteId, comment, dateAdded)
SELECT id, note_id, comment, date_added FROM event_log;
DROP TABLE event_log;
ALTER TABLE event_log_mig RENAME TO event_log;
CREATE TABLE "note_tree" (
`noteTreeId` 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,
`dateModified` TEXT NOT NULL,
PRIMARY KEY(`noteTreeId`)
);
INSERT INTO note_tree (noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified)
SELECT note_tree_id, note_id, parent_note_id, note_position, prefix, is_expanded, is_deleted, date_modified FROM notes_tree;
DROP TABLE notes_tree;
CREATE INDEX `IDX_note_tree_noteId` ON `note_tree` (
`noteId`
);
CREATE INDEX `IDX_note_tree_noteId_parentNoteId` ON `note_tree` (
`noteId`,
`parentNoteId`
);
CREATE TABLE "note_revisions" (
`noteRevisionId` TEXT NOT NULL PRIMARY KEY,
`noteId` TEXT NOT NULL,
`title` TEXT,
`content` TEXT,
`isProtected` INT NOT NULL DEFAULT 0,
`dateModifiedFrom` TEXT NOT NULL,
`dateModifiedTo` TEXT NOT NULL
);
INSERT INTO note_revisions (noteRevisionId, noteId, title, content, isProtected, dateModifiedFrom, dateModifiedTo)
SELECT note_history_id, note_id, note_title, note_text, is_protected, date_modified_from, date_modified_to FROM notes_history;
DROP TABLE notes_history;
CREATE INDEX `IDX_note_revisions_noteId` ON `note_revisions` (
`noteId`
);
CREATE INDEX `IDX_note_revisions_dateModifiedFrom` ON `note_revisions` (
`dateModifiedFrom`
);
CREATE INDEX `IDX_note_revisions_dateModifiedTo` ON `note_revisions` (
`dateModifiedTo`
);
CREATE TABLE `recent_notes_mig` (
`noteTreeId` TEXT NOT NULL PRIMARY KEY,
`notePath` TEXT NOT NULL,
`dateAccessed` TEXT NOT NULL,
isDeleted INT
);
INSERT INTO recent_notes_mig (noteTreeId, notePath, dateAccessed, isDeleted)
SELECT note_tree_id, note_path, date_accessed, is_deleted FROM recent_notes;
DROP TABLE recent_notes;
ALTER TABLE recent_notes_mig RENAME TO recent_notes;
CREATE TABLE images_mig
(
imageId TEXT PRIMARY KEY NOT NULL,
format TEXT NOT NULL,
checksum TEXT NOT NULL,
name TEXT NOT NULL,
data BLOB,
isDeleted INT NOT NULL DEFAULT 0,
dateModified TEXT NOT NULL,
dateCreated TEXT NOT NULL
);
INSERT INTO images_mig (imageId, format, checksum, name, data, isDeleted, dateModified, dateCreated)
SELECT image_id, format, checksum, name, data, is_deleted, date_modified, date_created FROM images;
DROP TABLE images;
ALTER TABLE images_mig RENAME TO images;
CREATE TABLE note_images
(
noteImageId TEXT PRIMARY KEY NOT NULL,
noteId TEXT NOT NULL,
imageId TEXT NOT NULL,
isDeleted INT NOT NULL DEFAULT 0,
dateModified TEXT NOT NULL,
dateCreated TEXT NOT NULL
);
INSERT INTO note_images (noteImageId, noteId, imageId, isDeleted, dateModified, dateCreated)
SELECT note_image_id, note_id, image_id, is_deleted, date_modified, date_created FROM notes_image;
DROP TABLE notes_image;
CREATE INDEX IDX_note_images_noteId ON note_images (noteId);
CREATE INDEX IDX_note_images_imageId ON note_images (imageId);
CREATE INDEX IDX_note_images_noteId_imageId ON note_images (noteId, imageId);
CREATE TABLE attributes_mig
(
attributeId TEXT PRIMARY KEY NOT NULL,
noteId TEXT NOT NULL,
name TEXT NOT NULL,
value TEXT,
dateCreated TEXT NOT NULL,
dateModified TEXT NOT NULL
);
INSERT INTO attributes_mig (attributeId, noteId, name, value, dateCreated, dateModified)
SELECT attribute_id, note_id, name, value, date_created, date_modified FROM attributes;
DROP TABLE attributes;
ALTER TABLE attributes_mig RENAME TO attributes;
CREATE INDEX IDX_attributes_noteId ON attributes (noteId);
CREATE UNIQUE INDEX IDX_attributes_noteId_name ON attributes (noteId, name);

View File

@ -1,4 +0,0 @@
UPDATE sync SET entityName = 'note_images' WHERE entityName = 'notes_image';
UPDATE sync SET entityName = 'note_tree' WHERE entityName = 'notes_tree';
UPDATE sync SET entityName = 'note_revisions' WHERE entityName = 'notes_history';
UPDATE sync SET entityName = 'note_reordering' WHERE entityName = 'notes_reordering';

View File

@ -1 +0,0 @@
DROP INDEX IDX_attributes_noteId_name;

View File

@ -1 +0,0 @@
ALTER TABLE attributes ADD COLUMN isDeleted INT NOT NULL DEFAULT 0;

View File

@ -1 +0,0 @@
ALTER TABLE attributes ADD COLUMN position INT NOT NULL DEFAULT 0;

View File

@ -1,7 +0,0 @@
CREATE TABLE IF NOT EXISTS "api_tokens"
(
apiTokenId TEXT PRIMARY KEY NOT NULL,
token TEXT NOT NULL,
dateCreated TEXT NOT NULL,
isDeleted INT NOT NULL DEFAULT 0
);

View File

@ -1 +0,0 @@
CREATE INDEX IDX_attributes_name_value ON attributes (name, value);

View File

@ -1,23 +0,0 @@
UPDATE attributes SET value = '' WHERE value IS NULL;
CREATE TABLE IF NOT EXISTS "attributes_mig"
(
attributeId TEXT PRIMARY KEY NOT NULL,
noteId TEXT NOT NULL,
name TEXT NOT NULL,
value TEXT NOT NULL DEFAULT '',
position INT NOT NULL DEFAULT 0,
dateCreated TEXT NOT NULL,
dateModified TEXT NOT NULL,
isDeleted INT NOT NULL
);
INSERT INTO attributes_mig (attributeId, noteId, name, value, position, dateCreated, dateModified, isDeleted)
SELECT attributeId, noteId, name, value, position, dateCreated, dateModified, isDeleted FROM attributes;
DROP TABLE attributes;
ALTER TABLE attributes_mig RENAME TO attributes;
CREATE INDEX IDX_attributes_noteId ON attributes (noteId);
CREATE INDEX IDX_attributes_name_value ON attributes (name, value);

View File

@ -1 +0,0 @@
UPDATE notes SET mime = 'application/javascript;env=frontend' WHERE type = 'code' AND mime = 'application/javascript';

View File

@ -1,38 +0,0 @@
CREATE TABLE "branches" (
`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,
`dateModified` TEXT NOT NULL,
PRIMARY KEY(`branchId`)
);
INSERT INTO branches (branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified)
SELECT noteTreeId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, dateModified FROM note_tree;
DROP TABLE note_tree;
CREATE INDEX `IDX_branches_noteId` ON `branches` (
`noteId`
);
CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` (
`noteId`,
`parentNoteId`
);
CREATE TABLE `recent_notes_mig` (
`branchId` TEXT NOT NULL PRIMARY KEY,
`notePath` TEXT NOT NULL,
`dateAccessed` TEXT NOT NULL,
isDeleted INT
);
INSERT INTO recent_notes_mig (branchId, notePath, dateAccessed, isDeleted)
SELECT noteTreeId, notePath, dateAccessed, isDeleted FROM recent_notes;
DROP TABLE recent_notes;
ALTER TABLE recent_notes_mig RENAME TO recent_notes;

View File

@ -1,22 +0,0 @@
create table labels
(
labelId TEXT not null primary key,
noteId TEXT not null,
name TEXT not null,
value TEXT default '' not null,
position INT default 0 not null,
dateCreated TEXT not null,
dateModified TEXT not null,
isDeleted INT not null
);
create index IDX_labels_name_value
on labels (name, value);
create index IDX_labels_noteId
on labels (noteId);
INSERT INTO labels (labelId, noteId, name, "value", "position", dateCreated, dateModified, isDeleted)
SELECT attributeId, noteId, name, "value", "position", dateCreated, dateModified, isDeleted FROM attributes;
DROP TABLE attributes;

View File

@ -1 +0,0 @@
UPDATE options SET name = 'note_revision_snapshot_time_interval' WHERE name = 'history_snapshot_time_interval';

View File

@ -1,14 +0,0 @@
UPDATE "options" SET "name" = 'passwordVerificationHash' WHERE "name" = 'password_verification_hash';
UPDATE "options" SET "name" = 'dbVersion' WHERE "name" = 'db_version';
UPDATE "options" SET "name" = 'passwordDerivedKeySalt' WHERE "name" = 'password_derived_key_salt';
UPDATE "options" SET "name" = 'documentId' WHERE "name" = 'document_id';
UPDATE "options" SET "name" = 'lastSyncedPull' WHERE "name" = 'last_synced_pull';
UPDATE "options" SET "name" = 'startNotePath' WHERE "name" = 'start_note_path';
UPDATE "options" SET "name" = 'lastSyncedPush' WHERE "name" = 'last_synced_push';
UPDATE "options" SET "name" = 'documentSecret' WHERE "name" = 'document_secret';
UPDATE "options" SET "name" = 'lastBackupDate' WHERE "name" = 'last_backup_date';
UPDATE "options" SET "name" = 'noteRevisionSnapshotTimeInterval' WHERE "name" = 'note_revision_snapshot_time_interval';
UPDATE "options" SET "name" = 'protectedSessionTimeout' WHERE "name" = 'protected_session_timeout';
UPDATE "options" SET "name" = 'encryptedDataKey' WHERE "name" = 'encrypted_data_key';
UPDATE "options" SET "name" = 'encryptedDataKeyIv' WHERE "name" = 'encrypted_data_key_iv';
UPDATE "options" SET "name" = 'passwordVerificationSalt' WHERE "name" = 'password_verification_salt';

View File

@ -1,7 +0,0 @@
UPDATE labels SET name = 'disableVersioning' WHERE name = 'disable_versioning';
UPDATE labels SET name = 'calendarRoot' WHERE name = 'calendar_root';
UPDATE labels SET name = 'hideInAutocomplete' WHERE name = 'hide_in_autocomplete';
UPDATE labels SET name = 'excludeFromExport' WHERE name = 'exclude_from_export';
UPDATE labels SET name = 'manualTransactionHandling' WHERE name = 'manual_transaction_handling';
UPDATE labels SET name = 'disableInclusion' WHERE name = 'disable_inclusion';
UPDATE labels SET name = 'appCss' WHERE name = 'app_css';

View File

@ -1,4 +0,0 @@
UPDATE labels SET name = 'redditId' WHERE name = 'reddit_id';
UPDATE labels SET name = 'redditKind' WHERE name = 'reddit_kind';
UPDATE labels SET name = 'redditCreatedUtc' WHERE name = 'reddit_created_utc';
UPDATE labels SET name = 'redditDateNote' WHERE name = 'reddit_date_note';

View File

@ -1,2 +0,0 @@
UPDATE labels SET value = 'frontendStartup' WHERE value = 'frontend_startup';
UPDATE labels SET value = 'backendStartup' WHERE value = 'backend_startup';

View File

@ -1,7 +0,0 @@
UPDATE labels SET name = 'dateData' WHERE name = 'date_data';
UPDATE labels SET name = 'dateNote' WHERE name = 'date_note';
UPDATE labels SET name = 'fileSize' WHERE name = 'file_size';
UPDATE labels SET name = 'hideInAutocomplete' WHERE name = 'hide_in_autocomplete';
UPDATE labels SET name = 'monthNote' WHERE name = 'month_note';
UPDATE labels SET name = 'originalFileName' WHERE name = 'original_file_name';
UPDATE labels SET name = 'yearNote' WHERE name = 'year_note';

View File

@ -1,5 +0,0 @@
ALTER TABLE note_revisions ADD type TEXT DEFAULT '' NOT NULL;
ALTER TABLE note_revisions ADD mime TEXT DEFAULT '' NOT NULL;
UPDATE note_revisions SET type = (SELECT type FROM notes WHERE notes.noteId = note_revisions.noteId);
UPDATE note_revisions SET mime = (SELECT mime FROM notes WHERE notes.noteId = note_revisions.noteId);

View File

@ -1,34 +0,0 @@
CREATE TABLE event_logc027
(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
noteId TEXT,
comment TEXT,
dateAdded TEXT NOT NULL
);
INSERT INTO event_logc027(id, noteId, comment, dateAdded) SELECT id, noteId, comment, dateAdded FROM event_log;
DROP TABLE event_log;
ALTER TABLE event_logc027 RENAME TO event_log;
CREATE TABLE IF NOT EXISTS "notes_mig" (
`noteId` TEXT NOT NULL,
`title` TEXT NOT NULL DEFAULT "unnamed",
`content` TEXT NOT NULL DEFAULT "",
`isProtected` INT NOT NULL DEFAULT 0,
`isDeleted` INT NOT NULL DEFAULT 0,
`dateCreated` TEXT NOT NULL,
`dateModified` TEXT NOT NULL,
type TEXT NOT NULL DEFAULT 'text',
mime TEXT NOT NULL DEFAULT 'text/html',
PRIMARY KEY(`noteId`)
);
INSERT INTO notes_mig (noteId, title, content, isProtected, isDeleted, dateCreated, dateModified, type, mime)
SELECT noteId, title, content, isProtected, isDeleted, dateCreated, dateModified, type, mime FROM notes;
DROP TABLE notes;
ALTER TABLE notes_mig RENAME TO notes;
CREATE INDEX `IDX_notes_isDeleted` ON `notes` (
`isDeleted`
);

View File

@ -1,5 +0,0 @@
INSERT INTO branches (branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, dateModified)
VALUES ('root', 'root', 'none', 0, null, 1, '2018-01-01T00:00:00.000Z');
INSERT INTO sync (entityName, entityId, sourceId, syncDate)
VALUES ('branches' ,'root', 'SYNC_FILL', '2018-01-01T00:00:00.000Z');

View File

@ -1 +0,0 @@
CREATE INDEX IDX_branches_parentNoteId ON branches (parentNoteId);

View File

@ -1,2 +0,0 @@
-- index confuses planner and is mostly useless anyway since we're mostly used in non-deleted notes (which are presumably majority)
DROP INDEX IDX_notes_isDeleted;

View File

@ -1,2 +0,0 @@
create index IDX_notes_type
on notes (type);

View File

@ -1,9 +0,0 @@
ALTER TABLE notes ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE branches ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE note_revisions ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE recent_notes ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE options ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE note_images ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE images ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE labels ADD hash TEXT DEFAULT "" NOT NULL;
ALTER TABLE api_tokens ADD hash TEXT DEFAULT "" NOT NULL;

View File

@ -1,30 +0,0 @@
ALTER TABLE branches ADD dateCreated TEXT NOT NULL DEFAULT '1970-01-01T00:00:00.000Z';
CREATE TABLE `event_log_mig` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`noteId` TEXT,
`comment` TEXT,
`dateCreated` TEXT NOT NULL
);
INSERT INTO event_log_mig (id, noteId, comment, dateCreated)
SELECT id, noteId, comment, dateAdded FROM event_log;
DROP TABLE event_log;
ALTER TABLE event_log_mig RENAME TO event_log;
ALTER TABLE options ADD dateCreated TEXT NOT NULL DEFAULT '1970-01-01T00:00:00.000Z';
CREATE TABLE `recent_notes_mig` (
`branchId` TEXT NOT NULL PRIMARY KEY,
`notePath` TEXT NOT NULL,
hash TEXT DEFAULT "" NOT NULL,
`dateCreated` TEXT NOT NULL,
isDeleted INT
);
INSERT INTO recent_notes_mig (branchId, notePath, hash, dateCreated, isDeleted)
SELECT branchId, notePath, hash, dateAccessed, isDeleted FROM recent_notes;
DROP TABLE recent_notes;
ALTER TABLE recent_notes_mig RENAME TO recent_notes;

View File

@ -1 +0,0 @@
UPDATE notes SET mime = 'text/html' WHERE type = 'render';

View File

@ -1,29 +0,0 @@
CREATE TABLE `event_log_mig` (
`eventId` TEXT NOT NULL PRIMARY KEY,
`noteId` TEXT,
`comment` TEXT,
`dateCreated` TEXT NOT NULL
);
INSERT INTO event_log_mig (eventId, noteId, comment, dateCreated)
SELECT id, noteId, comment, dateCreated FROM event_log;
DROP TABLE event_log;
ALTER TABLE event_log_mig RENAME TO event_log;
create table options_mig
(
optionId TEXT NOT NULL PRIMARY KEY,
name TEXT not null,
value TEXT,
dateModified INT,
isSynced INTEGER default 0 not null,
hash TEXT default "" not null,
dateCreated TEXT default '1970-01-01T00:00:00.000Z' not null
);
INSERT INTO options_mig (optionId, name, value, dateModified, isSynced, hash, dateCreated)
SELECT name || "_key", name, value, dateModified, isSynced, hash, dateCreated FROM options;
DROP TABLE options;
ALTER TABLE options_mig RENAME TO options;

View File

@ -1,2 +0,0 @@
INSERT INTO options (optionId, name, value, dateCreated, dateModified, isSynced)
VALUES ('zoomFactor_key', 'zoomFactor', '1.0', '2018-06-01T03:35:55.041Z', '2018-06-01T03:35:55.041Z', 0);

View File

@ -1 +0,0 @@
UPDATE labels SET name = 'archived' WHERE name = 'hideInAutocomplete'

View File

@ -1,2 +0,0 @@
INSERT INTO options (optionId, name, value, dateCreated, dateModified, isSynced)
VALUES ('theme_key', 'theme', 'white', '2018-06-01T03:35:55.041Z', '2018-06-01T03:35:55.041Z', 0);

View File

@ -1,15 +0,0 @@
create table options_mig
(
name TEXT not null PRIMARY KEY,
value TEXT,
dateModified INT,
isSynced INTEGER default 0 not null,
hash TEXT default "" not null,
dateCreated TEXT default '1970-01-01T00:00:00.000Z' not null
);
INSERT INTO options_mig (name, value, dateModified, isSynced, hash, dateCreated)
SELECT name, value, dateModified, isSynced, hash, dateCreated FROM options;
DROP TABLE options;
ALTER TABLE options_mig RENAME TO options;

Some files were not shown because too many files have changed in this diff Show More