From 10d089240a95cacc0ab247e1a67ae15203b9224e Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 29 Aug 2019 22:32:53 +0200 Subject: [PATCH] updated DB schema and initial options --- .../a2c75661-f9e2-478f-a69f-6a9409e69997.xml | 336 ++++++++---------- db/schema.sql | 45 +-- src/services/options_init.js | 19 +- 3 files changed, 182 insertions(+), 218 deletions(-) diff --git a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml index 150fa429d..e0790da91 100644 --- a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml +++ b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml @@ -1,12 +1,11 @@ - + 3.25.1 1 - 1 @@ -15,634 +14,597 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
1
- +
1
- - +
+ 1 TEXT|0s 1 - + 2 TEXT|0s 1 - + 3 TEXT|0s 1 - + 4 INT|0s 1 0 - + 5 TEXT|0s 1 "" - + 1 apiTokenId + 1 - + apiTokenId 1 sqlite_autoindex_api_tokens_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s 1 - + 3 TEXT|0s 1 - + 4 TEXT|0s 1 - + 5 TEXT|0s 1 '' - + 6 INT|0s 1 0 - + 7 TEXT|0s 1 - + 8 TEXT|0s 1 - + 9 INT|0s 1 - + 10 TEXT|0s 1 "" - + 11 int|0s 0 - + 1 attributeId + 1 - + noteId + - + name value + - + name + - + value + - + attributeId 1 sqlite_autoindex_attributes_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s 1 - + 3 TEXT|0s 1 - + 4 INTEGER|0s 1 - + 5 TEXT|0s - + 6 BOOLEAN|0s - + 7 INTEGER|0s 1 0 - + 8 TEXT|0s 1 - + 9 TEXT|0s 1 - + 10 TEXT|0s 1 "" - + 1 branchId + 1 - + noteId parentNoteId + - + noteId + - + parentNoteId + - + branchId 1 sqlite_autoindex_branches_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s - + 3 TEXT|0s - + 4 TEXT|0s 1 - + 1 eventId + 1 - + eventId 1 sqlite_autoindex_event_log_1 - + 1 TEXT|0s 1 - - 2 - TEXT|0s - 1 - - - 3 - TEXT|0s - 1 - - - 4 - TEXT|0s - 1 - - - 5 - TEXT|0s - 1 - "" - - - 6 - INTEGER|0s - 1 - 0 - - - 7 - TEXT|0s - 1 - - - 8 - TEXT|0s - 1 - - - 1 - linkId - 1 - - - noteId - - - targetNoteId - - - linkId - 1 - sqlite_autoindex_links_1 - - - 1 - TEXT|0s - 1 - - + 2 TEXT|0s NULL - + 3 TEXT|0s 1 "" - + 4 TEXT|0s 1 - + 1 noteId + 1 - + noteId 1 sqlite_autoindex_note_contents_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s 1 - + 3 TEXT|0s - + 4 TEXT|0s - + 5 INT|0s 1 0 - + 6 TEXT|0s 1 - + 7 TEXT|0s 1 - + 8 TEXT|0s 1 - + 9 TEXT|0s 1 - + 10 TEXT|0s 1 '' - + 11 TEXT|0s 1 '' - + 12 TEXT|0s 1 "" - + 1 noteRevisionId + 1 - + noteId + - + utcDateModifiedFrom + - + utcDateModifiedTo + - + noteRevisionId 1 sqlite_autoindex_note_revisions_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s 1 "note" - + 3 INT|0s 1 0 - + 4 TEXT|0s 1 'text' - + 5 TEXT|0s 1 'text/html' - + 6 TEXT|0s 1 "" - + 7 INT|0s 1 0 - + 8 TEXT|0s 1 - + 9 TEXT|0s 1 - + 10 TEXT|0s 1 - + 11 TEXT|0s 1 - + 1 noteId + 1 - + noteId 1 sqlite_autoindex_notes_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s - + 3 INTEGER|0s 1 0 - + 4 TEXT|0s 1 "" - + 5 TEXT|0s 1 - + 6 TEXT|0s 1 - + 1 name + 1 - + name 1 sqlite_autoindex_options_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s 1 - + 3 TEXT|0s 1 "" - + 4 TEXT|0s 1 - + 5 INT|0s - + 1 - branchId + noteId + 1 - - branchId + + noteId 1 sqlite_autoindex_recent_notes_1 - + 1 TEXT|0s 1 - + 2 TEXT|0s 1 - + 1 sourceId + 1 - + sourceId 1 sqlite_autoindex_source_ids_1 - + 1 text|0s - + 2 text|0s - + 3 text|0s - + 4 int|0s - + 5 text|0s - + 1 - + 2 - + 1 INTEGER|0s 1 1 - + 2 TEXT|0s 1 - + 3 TEXT|0s 1 - + 4 TEXT|0s 1 - + 5 TEXT|0s 1 - + entityName entityId + 1 - + utcSyncDate + - + id 1 diff --git a/db/schema.sql b/db/schema.sql index 2917ad59d..ed5627b59 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -70,17 +70,6 @@ CREATE TABLE IF NOT EXISTS "attributes" isDeleted INT not null, hash TEXT default "" not null, isInheritable int DEFAULT 0 NULL); -CREATE TABLE IF NOT EXISTS "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, - `utcDateCreated` TEXT NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`linkId`) -); CREATE TABLE IF NOT EXISTS "notes" ( `noteId` TEXT NOT NULL, `title` TEXT NOT NULL DEFAULT "note", @@ -95,6 +84,21 @@ CREATE TABLE IF NOT EXISTS "notes" ( `utcDateModified` TEXT NOT NULL, PRIMARY KEY(`noteId`) ); +CREATE TABLE IF NOT EXISTS "note_contents" ( + `noteId` TEXT NOT NULL, + `content` TEXT NULL DEFAULT NULL, + `hash` TEXT DEFAULT "" NOT NULL, + `utcDateModified` TEXT NOT NULL, + PRIMARY KEY(`noteId`) +); +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 +); CREATE UNIQUE INDEX `IDX_sync_entityName_entityId` ON `sync` ( `entityName`, `entityId` @@ -121,28 +125,9 @@ CREATE INDEX `IDX_branches_noteId_parentNoteId` ON `branches` ( 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 TABLE IF NOT EXISTS "note_contents" ( - `noteId` TEXT NOT NULL, - `content` TEXT NULL DEFAULT NULL, - `hash` TEXT DEFAULT "" NOT NULL, - `utcDateModified` TEXT NOT NULL, - PRIMARY KEY(`noteId`) -); -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 -); diff --git a/src/services/options_init.js b/src/services/options_init.js index dc730ca3a..9e54d6390 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -25,6 +25,8 @@ async function initSyncedOptions(username, password) { // passwordEncryptionService expects these options to already exist await optionService.createOption('encryptedDataKey', '', true); + await optionService.createOption('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"]', true); + await passwordEncryptionService.setDataKey(password, utils.randomSecureToken(16), true); } @@ -32,7 +34,11 @@ async function initNotSyncedOptions(initialized, startNotePath = 'root', opts = await optionService.createOption('openTabs', JSON.stringify([ { notePath: startNotePath, - active: 1 + active: true, + sidebar: { + visible: true, + widgets: [] + } } ]), false); await optionService.createOption('hoistedNoteId', 'root', false); @@ -58,6 +64,17 @@ async function initNotSyncedOptions(initialized, startNotePath = 'root', opts = await optionService.createOption('treeFontSize', '100', false); await optionService.createOption('detailFontSize', '110', false); + await optionService.createOption('sidebarMinWidth', '350', false); + await optionService.createOption('sidebarWidthPercent', '25', false); + + await optionService.createOption('showSidebarInNewTab', 'true', false); + + await optionService.createOption('noteInfoWidget', '{"enabled":true,"expanded":true,"position":10}', false); + await optionService.createOption('attributesWidget', '{"enabled":true,"expanded":true,"position":20}', false); + await optionService.createOption('linkMapWidget', '{"enabled":true,"expanded":true,"position":30}', false); + await optionService.createOption('noteRevisionsWidget', '{"enabled":true,"expanded":true,"position":40}', false); + await optionService.createOption('whatLinksHereWidget', '{"enabled":false,"expanded":true,"position":50}', false); + await optionService.createOption('initialized', initialized ? 'true' : 'false', false); }