feat(service): M2b — Postgres persistence (sqlx) behind a feature flag #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/m2b-postgres"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Roadmap M2b, step 2: real persistence.
postgresfeature is off by default → CI stays DB-less.Changes
Serialize/Deserializeon all types (Tree → JSONB; also the basis for the JSON API).sqlx(rustls/postgres/json/macros/migrate) behind featurepostgres.pg::PgimplementsTreeStore/QuotaStore/SessionStoreon aPgPoolwith runtime queries (no compile-time DB) — trees as JSONB, atomic quota viaINSERT…ON CONFLICT…WHERE used<limit, session upsert.migrations/0001_init.sql.tests/pg.rsgated on feature +DATABASE_URL(skips DB-less).Verification
just qagreen: defaultcargo testis DB-less;--all-featuresclippy compiles the pg path + sqlx.Traces: FR-ACC-09/13, FR-IMP-18 · tech-spec 02 §2.4, 12 §12.1.
postgresfeature- domain + trip: derive serde Serialize/Deserialize on all types (Tree → JSONB; also the basis for the JSON REST API). serde dep added. - service: optional sqlx (rustls, postgres, json, macros, migrate) behind a `postgres` feature — OFF by default so qa/CI need no database. - pg::Pg implements TreeStore/QuotaStore/SessionStore on a PgPool using runtime queries (no compile-time DB); trees stored as JSONB, atomic quota consume via INSERT…ON CONFLICT…WHERE used<limit, session upsert. - migrations/0001_init.sql (users/trees/quotas/sessions). - tests/pg.rs: gated on feature + DATABASE_URL — skips DB-less. Verified against a real postgres:16: JSONB round-trip, session adopt, quota consume/exceed/refund all pass. just qa green (default DB-less; --all-features clippy compiles the pg path + sqlx). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>