Appearance
Migration Authoring
See also: Data Relationships, Admin Runbooks, Release Process, ADR: Pre-v1 Store Migration Re-Baseline, ADR: Migration Atomicity Hardening and Pitchfork-First Local Postgres Operations
This page is the maintainer checklist for adding migrations after the active V17 baseline.
Source of Truth
- libsql and SQLite migrations:
- PostgreSQL migrations:
- store registry and migration runner:
- local Postgres tasks:
Invariants
- Fresh databases start from one active
V17baseline per backend. - Databases with pre-baseline
V1throughV16history are recreated, not upgraded in place. - New migrations use the next shared version number for both backends.
- libsql/SQLite and PostgreSQL migrations must stay logically equivalent.
- Migration SQL and migration-history writes must remain atomic.
- Store tests and smoke checks should cover both backends when schema behavior changes.
Authoring Checklist
- Pick the next migration version.
- Add matching files under both migration directories.
- Keep names descriptive, for example
V18__route_compatibility_profiles.sql. - Update the migration registry if the runner requires an explicit include.
- Add or update store tests for new constraints, indexes, and repository behavior.
- Run the libsql/SQLite path locally.
- Run the PostgreSQL path locally.
- Update data-model docs when the entity graph changes.
- Update admin/user docs when the migration changes visible behavior.
- Add or update an ADR when the schema change reflects an architectural decision.
Local Validation
Use mise tasks instead of ad hoc database commands.
bash
mise run gateway-migrate
mise run postgres-start
mise run gateway-migrate-prod
mise run test-rust-postgres
mise run test-gateway-postgres-smokeFor full pre-handoff validation, use:
bash
mise run lint
mise run testDocumentation Triggers
Update data-relationships.md when a migration changes:
- ownership or identity relationships
- request-log or usage-ledger shape
- budget tables or enforcement inputs
- provider, model, route, capability, or compatibility tables
- generated admin API payloads that expose new persisted fields
Update admin-runbooks when the migration changes admin recovery, reset, upgrade, or first-access steps.
What This Page Does Not Own
- schema relationship reference:
- recovery and reset procedures:
- release mechanics: