Skip to content

Numbered migration files instead of one hand-typed SCHEMA_VERSION #424

Closed

Description

@itsskofficial

sentient/store/db.py keeps the schema version as one hand-typed line, SCHEMA_VERSION = 12, with a growing comment, and the steps that update an older database are store.ensure_column calls spread over Store.open and a dozen services' start(). Two pull requests that each change the schema both edit that one line and the same block, and silently pick the same number (#401 just took 12). Columns also arrive without a bump (messages.checks, group chats, skill checks), and nothing checks that a new database and an updated old one end up with the same shape.

Proposal

  • One file per migration step in sentient/store/migrations/ (0013_<name>.py, or .sql where plain SQL is enough). SCHEMA_VERSION becomes the highest number, derived from the files.
  • Port the existing steps faithfully, in order, keeping the snapshot taken before a migration (Backup, restore and snapshots before migrations #151) and the difference between a new database and an existing one.
  • A test that fails when two files share a number, the numbering has a gap, or schema.sql for a new database disagrees with a database migrated from an old version (tables, columns, indexes).
  • "Add a migration" steps in docs/DEVELOPING.md, and an ADR, since this changes how ADR 0003 says columns are added.

Activity

  1. added
    area: engine
    on Oct 17, 2026
  2. added a commit that references this issue on Oct 17, 2026
    980a59c
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

    area: engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions