From d45a59aa4ec37f6f0f39be1a46c56683cf111466 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 12 Feb 2021 23:30:11 +0100 Subject: [PATCH] sync fixes --- db/migrations/0173__isErased_in_entity_changes.sql | 4 ++-- db/migrations/0174__move_hash_to_entity_changes.sql | 4 ++-- db/schema.sql | 13 ++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/db/migrations/0173__isErased_in_entity_changes.sql b/db/migrations/0173__isErased_in_entity_changes.sql index af10ffac4..b2dada076 100644 --- a/db/migrations/0173__isErased_in_entity_changes.sql +++ b/db/migrations/0173__isErased_in_entity_changes.sql @@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( `utcDateChanged` TEXT NOT NULL, `isSynced` INTEGER NOT NULL); -INSERT INTO mig_entity_changes (entityName, entityId, hash, sourceId, isSynced, utcDateChanged, isErased) -SELECT entityName, entityId, '', sourceId, isSynced, 'now', 0 FROM entity_changes; +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 = (SELECT isErased FROM notes WHERE noteId = entityId) 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'; diff --git a/db/migrations/0174__move_hash_to_entity_changes.sql b/db/migrations/0174__move_hash_to_entity_changes.sql index da93b5961..c64c7ad77 100644 --- a/db/migrations/0174__move_hash_to_entity_changes.sql +++ b/db/migrations/0174__move_hash_to_entity_changes.sql @@ -9,8 +9,8 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( `utcDateChanged` TEXT NOT NULL ); -INSERT INTO mig_entity_changes (entityName, entityId, hash, sourceId, isSynced, isErased, utcDateChanged) - SELECT entityName, entityId, '', sourceId, isSynced, isErased, utcDateChanged FROM entity_changes; +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'; diff --git a/db/schema.sql b/db/schema.sql index 00ad3a684..989585170 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -68,13 +68,6 @@ CREATE TABLE IF NOT EXISTS "options" utcDateCreated TEXT not null, utcDateModified TEXT NOT NULL ); -CREATE TABLE IF NOT EXISTS "recent_notes" -( - noteId TEXT not null primary key, - notePath TEXT not null, - utcDateCreated TEXT not null, - isDeleted INT NOT NULL DEFAULT 0 -); CREATE TABLE IF NOT EXISTS "attributes" ( attributeId TEXT not null primary key, @@ -110,3 +103,9 @@ CREATE INDEX IDX_attributes_noteId_index on attributes (noteId); CREATE INDEX IDX_attributes_value_index on attributes (value); +CREATE TABLE IF NOT EXISTS "recent_notes" +( + noteId TEXT not null primary key, + notePath TEXT not null, + utcDateCreated TEXT not null +);