diff --git a/lib/core/src/persist/migrations.rs b/lib/core/src/persist/migrations.rs index 31b88d6e..4353f855 100644 --- a/lib/core/src/persist/migrations.rs +++ b/lib/core/src/persist/migrations.rs @@ -186,7 +186,8 @@ pub(crate) fn current_migrations() -> Vec<&'static str> { "CREATE TABLE IF NOT EXISTS sync_state( data_id TEXT NOT NULL PRIMARY KEY, record_id TEXT NOT NULL UNIQUE, - record_revision INTEGER NOT NULL + record_revision INTEGER NOT NULL, + is_local bool NOT NULL DEFAULT 1 ) STRICT;", "CREATE TABLE IF NOT EXISTS sync_settings( key TEXT NOT NULL PRIMARY KEY UNIQUE, diff --git a/lib/core/src/persist/sync.rs b/lib/core/src/persist/sync.rs index feab08b4..84e59250 100644 --- a/lib/core/src/persist/sync.rs +++ b/lib/core/src/persist/sync.rs @@ -19,7 +19,8 @@ impl Persister { SELECT data_id, record_id, - record_revision + record_revision, + is_local FROM sync_state {where_clause_str} " @@ -32,6 +33,7 @@ impl Persister { data_id, record_id: row.get(1)?, record_revision: row.get(2)?, + is_local: row.get(3)?, }), None => None, }) @@ -56,13 +58,14 @@ impl Persister { con.execute( " - INSERT OR REPLACE INTO sync_state(data_id, record_id, record_revision) - VALUES (:data_id, :record_id, :record_revision) + INSERT OR REPLACE INTO sync_state(data_id, record_id, record_revision, is_local) + VALUES (:data_id, :record_id, :record_revision, :is_local) ", named_params! { ":data_id": &sync_state.data_id, ":record_id": &sync_state.record_id, ":record_revision": &sync_state.record_revision, + ":is_local": &sync_state.is_local, }, )?; diff --git a/lib/core/src/sync/model/mod.rs b/lib/core/src/sync/model/mod.rs index 32dceea3..bbc0c1c1 100644 --- a/lib/core/src/sync/model/mod.rs +++ b/lib/core/src/sync/model/mod.rs @@ -36,6 +36,7 @@ pub(crate) struct SyncState { pub(crate) data_id: String, pub(crate) record_id: String, pub(crate) record_revision: u64, + pub(crate) is_local: bool, } pub(crate) struct SyncSettings {