Add libSQL/Turso database backend (1.6.0) - #4
Merged
Merged
Conversation
Adds a third storage backend alongside SQLite and PostgreSQL: remote
libSQL via Turso, accessed through the pure-Go libsql-client-go driver
(no CGO required). The schema and SQL are SQLite-compatible, so the
existing migrations/sqlite/*.sql files run unchanged and the SQLiteRepo
implementation is reused — only the connection setup differs.
Behavioral notes:
- No client-side pragmas (journal_mode, busy_timeout, synchronous,
foreign_keys) — those are server-controlled on Turso.
- Transactions begin as deferred; the (word, status) UNIQUE constraint
remains the source of truth for collision resolution.
Configuration: driver "libsql" with database.libsql.{url,auth_token},
plus matching WORDSTORE_DATABASE_LIBSQL_{URL,AUTH_TOKEN} env overrides.
Integration tests live in internal/repository/libsql_test.go and skip
unless WATCHWORD_TEST_TURSO_URL is set, so builds without the secret
still pass. Each test uses a random word prefix and cleans up its own
rows on teardown. CI wires the secrets into the main test job and adds
a dedicated turso job with continue-on-error: true for visibility.
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
libsql-client-godriver — no CGO required.migrations/sqlite/*.sqlfiles run unchanged and theSQLiteRepoimplementation is reused. Only connection setup differs.libsqlwithdatabase.libsql.{url, auth_token}andWORDSTORE_DATABASE_LIBSQL_{URL, AUTH_TOKEN}env overrides.internal/repository/libsql_test.goskip cleanly unlessWATCHWORD_TEST_TURSO_URLis set, so builds without the secret still pass. Each test uses a randomwwtest_<hex>_*word prefix and cleans up its own rows on teardown.testjob; dedicatedtursojob withcontinue-on-error: truefor visibility.Behavioral notes (vs. local SQLite backend)
journal_mode,busy_timeout,synchronous,foreign_keysare server-controlled on Turso; the URI-pragma format used by the local backend is not applied._txlock=immediateequivalent on libsql; the(word, status)UNIQUE constraint remains the source of truth for collision resolution.Test plan
TestLibSQL_*integration tests pass against a localturso devserver (in-memory and file-backed).watchword-ciTurso DB (aws-eu-west-1).store_entrythenget_entry_by_wordthenlist_entriesagainst libsql.entry_type,created_bycolumns plus partial index and unique constraint all created.go vet ./...clean,go test -race ./...green,CGO_ENABLED=0 go buildworks.