Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
updated schema
azivner9760eb71d39f
diff --git a/db/schema.sql b/db/schema.sqlindex 4dd4ce708c..1e6005c524 100644--- a/db/schema.sql+++ b/db/schema.sql@@ -1,15 +1,21 @@CREATE TABLE IF NOT EXISTS "options" (`opt_name` TEXT NOT NULL PRIMARY KEY,`opt_value` TEXT,- `is_synced` INTEGER NOT NULL DEFAULT 0,`date_modified` INT-);+, is_synced INTEGER NOT NULL DEFAULT 0);CREATE TABLE IF NOT EXISTS "sync" (`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);+CREATE UNIQUE INDEX `IDX_sync_entity_name_id` ON `sync` (+ `entity_name`,+ `entity_id`+);+CREATE INDEX `IDX_sync_sync_date` ON `sync` (+ `sync_date`+);CREATE TABLE `source_ids` (`source_id` TEXT NOT NULL,`date_created` TEXT NOT NULL,@@ -22,9 +28,12 @@ CREATE TABLE IF NOT EXISTS "notes" (`is_protected` INT NOT NULL DEFAULT 0,`is_deleted` INT NOT NULL DEFAULT 0,`date_created` TEXT NOT NULL,- `date_modified` TEXT NOT NULL,+ `date_modified` TEXT NOT NULL, type TEXT NOT NULL DEFAULT 'text', mime TEXT NOT NULL DEFAULT 'text',PRIMARY KEY(`note_id`));+CREATE INDEX `IDX_notes_is_deleted` ON `notes` (+ `is_deleted`+);CREATE TABLE `event_log` (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,`note_id` TEXT,@@ -43,6 +52,9 @@ CREATE TABLE IF NOT EXISTS "notes_tree" (`date_modified` TEXT NOT NULL,PRIMARY KEY(`note_tree_id`));+CREATE INDEX `IDX_notes_tree_note_id` ON `notes_tree` (+ `note_id`+);CREATE TABLE IF NOT EXISTS "notes_history" (`note_history_id` TEXT NOT NULL PRIMARY KEY,`note_id` TEXT NOT NULL,@@ -52,38 +64,25 @@ CREATE TABLE IF NOT EXISTS "notes_history" (`date_modified_from` TEXT NOT NULL,`date_modified_to` TEXT NOT NULL);+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`+);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);-CREATE UNIQUE INDEX `IDX_sync_entity_name_id` ON `sync` (- `entity_name`,- `entity_id`-);-CREATE INDEX `IDX_sync_sync_date` ON `sync` (- `sync_date`-);-CREATE INDEX `IDX_notes_is_deleted` ON `notes` (- `is_deleted`-);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 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`-);CREATE TABLE images(image_id TEXT PRIMARY KEY NOT NULL,@@ -95,7 +94,6 @@ CREATE TABLE imagesdate_modified TEXT NOT NULL,date_created TEXT NOT NULL);-CREATE TABLE notes_image(note_image_id TEXT PRIMARY KEY NOT NULL,@@ -105,11 +103,9 @@ CREATE TABLE notes_imagedate_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);-CREATE TABLE attributes(attribute_id TEXT PRIMARY KEY NOT NULL,@@ -119,6 +115,5 @@ CREATE TABLE attributesdate_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);\ No newline at end of file+CREATE UNIQUE INDEX attributes_note_id_name_index ON attributes (note_id, name);