You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/quotesdb/.beans/quotesdb-td4l--triage-local...

2.8 KiB

title status type priority created_at updated_at
[TRIAGE] Local dev config: Turso (file SQLite) vs D1 binding selection strategy completed task critical 2026-03-10T23:32:06Z 2026-03-10T23:32:06Z
This is a triage decision ticket. It must be resolved before dependent implementation tickets can proceed. Local dev config: should the API use Turso (file-backed SQLite via libsql) or a D1 binding (via wrangler dev) for local development? How is the selection made at runtime? 1. **Turso/libsql** — lightweight local SQLite file, no Cloudflare account needed. Connection string via env var. SQLx-compatible. 2. **Wrangler D1 local** — `wrangler dev` spins up a local D1 emulator. Closer to production but requires wrangler and a Cloudflare account even locally. 3. **Plain SQLite via sqlx** — use sqlx's SQLite driver with a local file. No Turso dependency needed for dev. **Chosen approach: rusqlite with a local SQLite file — a variant of Option 3, but using rusqlite instead of sqlx.**

This decision is a direct consequence of TRIAGE e8a330 (already resolved): SQLx is NOT compatible with Cloudflare Workers/D1 at all. The chosen architecture is cfg(target_arch = "wasm32") compile-time split:

  • wasm32 (production) → workers-rs D1Database bindings
  • native (local dev + tests) → rusqlite + tokio-rusqlite with a local .sqlite file

Rationale for rusqlite over Turso:

  • No additional dependency or service (Turso = libsql client + server/cloud)
  • rusqlite with features = ["bundled"] compiles SQLite in — zero system dependencies
  • cargo run just works without any account, credentials, or external tooling
  • cargo test works the same way — tests use the rusqlite path automatically

Rationale for rusqlite over wrangler D1 local:

  • No wrangler, no Cloudflare account required for local dev or CI
  • Eliminates a major developer friction point
  • Integration tests use NativeRepository (rusqlite) directly without spawning wrangler

Selection mechanism: compile-time via cfg(target_arch = "wasm32"), not runtime env var. The DATABASE_URL env var controls the SQLite file path (default: ./quotesdb.sqlite).

Port note: Native API server binds to localhost:3000 (Trunk UI dev server uses localhost:8080). Port conflict found and fixed in ticket 00aff0 (was 8080, corrected to 3000).

Updated:

  • Ticket 00aff0 (DB abstraction): corrected native server port 8080 → 3000
  • Ticket af56a7 (local dev docs): updated title and body to reflect rusqlite approach
  • Ticket 9c9546 (new): create .env.example documenting DATABASE_URL
`chore(quotesdb): resolve triage — local-dev-config-turso-file-sqlite-vs-d1-binding-selection-s`