Skip to content

Commit c86ef3b

Browse files
AI comments
1 parent caf5370 commit c86ef3b

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

crates/core/src/migrations.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ DROP TABLE ps_sync_state_old;
488488
// After copying, the `$local` row is deleted: version 14 tracks this state exclusively in
489489
// ps_kv, so ps_buckets only contains real sync buckets. The down migration recreates the
490490
// row from ps_kv when needed.
491+
//
492+
// DROP COLUMN requires SQLite 3.35+; the extension already refuses to load below
493+
// MIN_SQLITE_VERSION_NUMBER (3.44), so this is safe in the up path.
491494
let up = "\
492495
DELETE FROM ps_kv
493496
WHERE key IN (

crates/core/src/sync/storage_adapter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ WHERE bucket = ?1",
528528
/// `next_checkpoint_request_id`.
529529
///
530530
/// Returns the target op value from before this call. When `target_op` is `None`, this only
531-
/// reads the current value.
531+
/// reads the current value. A `target_op` of zero clears the stored target, removing the apply
532+
/// gate entirely; any other value overwrites it.
532533
///
533534
/// Negative values are rejected when parsing the `powersync_control` payload, before this is
534535
/// called.

crates/core/src/view_admin.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ fn trigger_resync(db: *mut sqlite::sqlite3, state: &DatabaseState) -> Result<(),
163163
}
164164
}
165165

166-
db.exec_safe("UPDATE ps_buckets SET last_applied_op = 0 WHERE name != '$local'")
166+
// Since migration v14, ps_buckets only contains real sync buckets: the synthetic `$local`
167+
// bucket has moved to ps_kv, so no filter is needed here.
168+
db.exec_safe("UPDATE ps_buckets SET last_applied_op = 0")
167169
.into_db_result(db)?;
168170
Ok(Default::default())
169171
}

dart/test/sync_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,20 @@ void _syncTests<T>({
468468
invokeControlRaw('seed_checkpoint_request_id', 5);
469469
expect(lastRequestedCheckpointRequestId(), 5);
470470
expect(nextCheckpointRequestId(), 6);
471+
472+
// A NULL seed is stored as 0, restarting the counter. Forwarding a raw NULL service response
473+
// while a counter exists resets it - SDKs must reconcile before seeding.
474+
invokeControlRaw('seed_checkpoint_request_id', null);
475+
expect(lastRequestedCheckpointRequestId(), 0);
476+
expect(nextCheckpointRequestId(), 1);
477+
});
478+
479+
syncTest('accepts text checkpoint request ids when seeding', (_) {
480+
invokeControlRaw('start', null);
481+
invokeControlRaw('seed_checkpoint_request_id', '41');
482+
483+
expect(lastRequestedCheckpointRequestId(), 41);
484+
expect(nextCheckpointRequestId(), 42);
471485
});
472486

473487
syncTest('requires checkpoint request state before allocating checkpoint ids',

0 commit comments

Comments
 (0)