Skip to content

Add libSQL/Turso database backend (1.6.0) - #4

Merged
glani merged 1 commit into
mainfrom
1.6.0-turso
May 2, 2026
Merged

Add libSQL/Turso database backend (1.6.0)#4
glani merged 1 commit into
mainfrom
1.6.0-turso

Conversation

@glani

@glani glani commented May 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a libSQL/Turso backend alongside SQLite and PostgreSQL, using the pure-Go libsql-client-go driver — no CGO required.
  • libSQL is SQLite-compatible at the schema/SQL level, so the existing migrations/sqlite/*.sql files run unchanged and the SQLiteRepo implementation is reused. Only connection setup differs.
  • New config: driver libsql with database.libsql.{url, auth_token} and WORDSTORE_DATABASE_LIBSQL_{URL, AUTH_TOKEN} env overrides.
  • Integration tests under internal/repository/libsql_test.go skip cleanly unless WATCHWORD_TEST_TURSO_URL is set, so builds without the secret still pass. Each test uses a random wwtest_<hex>_* word prefix and cleans up its own rows on teardown.
  • CI: secrets wired into the main test job; dedicated turso job with continue-on-error: true for visibility.
  • README has a top-of-page Turso callout plus a deeper config section.

Behavioral notes (vs. local SQLite backend)

  • No client-side pragmas. journal_mode, busy_timeout, synchronous, foreign_keys are server-controlled on Turso; the URI-pragma format used by the local backend is not applied.
  • Deferred transactions. No _txlock=immediate equivalent on libsql; the (word, status) UNIQUE constraint remains the source of truth for collision resolution.

Test plan

  • All 5 TestLibSQL_* integration tests pass against a local turso dev server (in-memory and file-backed).
  • All 5 pass against the hosted watchword-ci Turso DB (aws-eu-west-1).
  • End-to-end MCP roundtrip via stdio: store_entry then get_entry_by_word then list_entries against libsql.
  • Migrations 001-004 apply cleanly; entry_type, created_by columns plus partial index and unique constraint all created.
  • go vet ./... clean, go test -race ./... green, CGO_ENABLED=0 go build works.
  • Tests skip cleanly when env unset (verified before secret was added).
  • CI green on this PR (will verify after push).

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.
@glani
glani merged commit bfd1657 into main May 2, 2026
12 checks passed
@glani
glani deleted the 1.6.0-turso branch May 2, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant