test(driver-sql): autonumber survives a driver restart (#1603)#1609
Merged
Conversation
Deterministic proof of the persistence guarantee behind the autonumber consolidation: a FILE-backed sqlite DB and two independent SqlDriver instances on the same file. After tearing down driver #1 (in-memory counters gone), a fresh driver #2 continues the sequence (CTR-0003, CTR-0004) instead of resetting to CTR-0001, and per-tenant sequences stay independent across the restart. A non-persistent counter would re-mint a duplicate here. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Locks in the persistence guarantee behind the #1603 autonumber consolidation (merged in #1608) with a deterministic regression test — no manual restart of a running server required.
A file-backed sqlite DB and two independent
SqlDriverinstances pointed at the same file:CTR-0001,CTR-0002, thendisconnect()(in-memory state gone).CTR-0003,CTR-0004.A non-persistent counter would reset to
CTR-0001here and mint a duplicate. A second case proves per-tenant sequences stay independent across the restart.This is the "survives restart" verification that was previously only argued via the bootstrap-from-existing-data test; now it's exercised directly through teardown + reconnect.
Testing
pnpm --filter @objectstack/driver-sql test— new filesql-driver-autonumber-persistence.test.ts(2 tests) passes; no changeset (test-only).🤖 Generated with Claude Code