Skip to content

Make db/tables.py + Alembic revisions the single schema source (after #4175) #746

Open

Description

@AndriiPasternak31

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

  1. Freeze the baseline: 0001_baseline carries its own DDL and stops importing db/schema.py. Existing databases already have an alembic_version row and do not re-run it. A fresh build must still reach the same head schema through the chain.
  2. Remove db/schema.py and move any non-DDL callers.
  3. Add a CI check that fails when db/tables.py and the Alembic head disagree (alembic check or equivalent autogenerate comparison).
  4. Remove the CI gate: fail PRs that add a migration without updating schema.py #713 gate and the schema parity guards this replaces.
  5. Update Invariant Feature/vector log retention #3 in docs/memory/architecture.md, CLAUDE.md Rule 9 and the database area file.

Acceptance criteria

  • A fresh PostgreSQL built by alembic upgrade head matches the pre-change head schema (tables, columns, indexes, triggers)
  • db/schema.py is gone and 0001_baseline imports no live schema module
  • A schema change touches only db/tables.py and one Alembic revision
  • CI fails when db/tables.py and the Alembic head diverge

References

Activity

  1. added
    complexity-high
    status-incubating
    on Jun 12, 2026
  2. added a commit that references this issue on Jul 8, 2026
  3. changed the title [-]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)[/+] on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-highpriority-p3status-incubatingtheme-devextype-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions