Repository navigation
Open
Labels
complexity-highComplexity: high (board points 13)priority-p3Nice-to-havestatus-incubatingIdea under consideration — pre-Todo, not yet greenlit for developmenttheme-devexTheme: DevExtype-refactorCode improvement
Description
Summary
A schema change on PostgreSQL is written by hand in three places: db/schema.py, db/tables.py and an Alembic revision. Make db/tables.py plus Alembic revisions the only schema sources.
0001_baseline builds a fresh PostgreSQL by importing the DDL currently in db/schema.py, so that file has to stay correct at head, and later revisions then run on top of it. alembic/env.py already targets db/tables.py MetaData.
Sequencing
Blocked by: #4175
#4175 removes the SQLite track: db/migrations.py, the bespoke runner and the SQLite half of the dual-track rule. This issue covers what remains after that.
Scope
- Freeze the baseline:
0001_baselinecarries its own DDL and stops importingdb/schema.py. Existing databases already have analembic_versionrow and do not re-run it. A fresh build must still reach the same head schema through the chain. - Remove
db/schema.pyand move any non-DDL callers. - Add a CI check that fails when
db/tables.pyand the Alembic head disagree (alembic checkor equivalent autogenerate comparison). - Remove the CI gate: fail PRs that add a migration without updating schema.py #713 gate and the schema parity guards this replaces.
- Update Invariant Feature/vector log retention #3 in
docs/memory/architecture.md,CLAUDE.mdRule 9 and the database area file.
Acceptance criteria
- A fresh PostgreSQL built by
alembic upgrade headmatches the pre-change head schema (tables, columns, indexes, triggers) -
db/schema.pyis gone and0001_baselineimports no live schema module - A schema change touches only
db/tables.pyand one Alembic revision - CI fails when
db/tables.pyand the Alembic head diverge
References
- Remove the SQLite backend: end-of-support passed 2026-09-01 and no issue owns the code removal #4175 (SQLite removal)
- CI gate: fail PRs that add a migration without updating schema.py #713, PR ci(schema): schema.py vs migrations.py parity gate (#713) #745 (the current drift gate)
- Schema Validation: 11 tables + 14 columns missing from schema.py (invariant #3 violated) #691, PR fix(schema): backfill schema.py to match migrations.py reality (#691) #712 (the drift that motivated the gate)
- feat(db): adopt Alembic for PostgreSQL migrations (retire SQLite-only bespoke runner) #1183 (Alembic for PostgreSQL)
docs/memory/architecture.md, Invariant Feature/vector log retention #3
Metadata
Metadata
Assignees
Labels
complexity-highComplexity: high (board points 13)priority-p3Nice-to-havestatus-incubatingIdea under consideration — pre-Todo, not yet greenlit for developmenttheme-devexTheme: DevExtype-refactorCode improvement
Activity
feat(db): adopt Alembic for PostgreSQL migrations — Phase 1 (#1183) (#…
docs(db): set SQLite end-of-support to September 1, 2026 + Postgres m…
Release: v0.8.0 (#1529)
merge-train: declare idx_users_email_unique in db/tables.py (#3085)
fix(auth): a sign-in email is proven, unique, and written in one plac…
refactor(a2a): mark the rc-era A2A columns inert and close §32.7 (ent…
refactor(a2a): every inbound A2A call needs a credential — drop the k…
[-]Collapse schema.py + migrations.py into single source of truth (follow-up to #713)[/-][+]Make db/tables.py + Alembic revisions the single schema source (after #4175)[/+]