Alembic
$ alembic Community Med Riskalembic is the standard schema migration tool for SQLAlchemy projects. It inspects live database state (alembic current), lists revision graphs (alembic history), autogenerates Python migration scripts (revision --autogenerate), and emits dry-run DDL via --sql offline mode.
pip install alembic alembic imports your repository's SQLAlchemy Base.metadata models and env.py directly from Python; MCP cannot substitute for local project code evaluation.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Runs completely non-interactively with --sql offline SQL generation, current, and history, though outputs are plain text/SQL rather than --json.
- Non-interactive CLI with
--sqloffline preview; no--jsonoutput
--sql offline mode enables pure DDL review without DB writes, and revision --autogenerate produces reviewable Python files before execution.
--sqloffline mode generates SQL scripts without mutating the database
Standard PyPI package installed in the project's Python virtualenv across macOS, Linux, and Windows.
- Distributed on PyPI (
alembic); runs inside project Python env
Integrates SQLAlchemy model diffing, branching/merge revision histories, and offline DBA SQL export.
- Supports
--autogenerate, branching (branches/merge), and--sqloffline output
Official SQLAlchemy project (sqlalchemy/alembic) under MIT license.
- Official
sqlalchemy/alembicrepository under MIT
Thorough CLI and cookbook documentation at alembic.sqlalchemy.org.
- Official docs at alembic.sqlalchemy.org
Security, Auth & Guardrails
Configured via alembic.ini (sqlalchemy.url) or Python env.py reading DATABASE_URL / app settings from the environment.
100% free and MIT open-source.
# Alembic Agent Rules - Always inspect generated `--autogenerate` scripts before running `alembic upgrade head`. - Use `alembic upgrade <from>:<to> --sql` to preview generated DDL offline before applying to shared DBs. - Never commit plaintext credentials into `alembic.ini`; inject `sqlalchemy.url` in `env.py` from env vars.
Agent-Ready Command Recipes
Safe Read-Only Queries
alembic current
Queries alembic_version and reports the active revision ID(s) on the target database.
--sql) alembic upgrade head --sql
Generates the raw SQL DDL statements for all pending migrations in offline mode without touching the DB.
Controlled Writes & Previews
alembic revision --autogenerate -m "add_user_index"
Diffs target_metadata against the live DB and writes a Python revision file for review.
Strengths for Agents
- +
--sqloffline mode outputs exact migration DDL for review before execution. - +
revision --autogeneratedetects model changes against the database schema automatically.
Caveats & Pitfalls
- ! No
--jsonoutput mode oncurrent,history, orheads. - ! Requires the project's Python virtual environment and database drivers to evaluate
env.py.