powersync_client_id() / powersync_last_synced_at() / powersync_clear() #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for:
powersync_client_id()
This returns an unique uuid per client. This is configured once when initializing the powersync tables.
This allows us to:
A new optional parameter will be added to the protocol for this.
powersync_last_synced_at()
This returns a persisted timestamp of the last synced at time. This should replace the
SELECT 1 FROM ps_buckets WHERE last_applied_op > 0 LIMIT 1
query currently used in clients, and will work even when no data was synced.powersync_clear()
This clears the database.
select powersync_clear(1)
to delete everything,select powersync_clear(0)
to preserve local tables.For the new ps_kv table, this clears last_synced_at, but not client_id.
This contains a workaround to trigger one update notification for each table, while still using the sqlite truncate optimization for the majority of rows.
This should replace the delete logic that is currently implemented in each client separately.
Internals
This now implements down migrations, which allows a developer to downgrade the SDK to older versions.
powersync_client_id
andpowersync_last_synced_at
are both stored in a newps_kv
table.Tests for the new functionality are implemented here: powersync-ja/powersync.dart#148
This PR removes lots of unused (incomplete) code, and fixes some lint issues.