Alembic
Database migrations tool for SQLAlchemy with autogenerate and transactional DDL
Repository Health
Technical Analysis
Alembic is a lightweight database migration tool written by the author of SQLAlchemy. It manages the incremental, versioned evolution of your relational schema through migration scripts organized as a directed-acyclic graph, letting you upgrade and downgrade a database through simple, ordered steps.
Beyond hand-written migrations, Alembic can autogenerate candidate migration scripts by comparing your SQLAlchemy models against the live database, emit changes as transactional DDL, and render migrations to plain SQL for DBA-driven workflows. It supports branching, merging, and multi-root version graphs, and includes batch (move-and-copy) migrations to work around SQLite’s limited ALTER support.
What You Get
- A CLI-driven migration workflow with revision, upgrade, downgrade, history, and stamp commands
- Autogeneration of candidate migrations by diffing SQLAlchemy models against the live database schema
- A concise operations API (op.add_column, op.alter_column, op.create_table) that avoids re-declaring full Table structures
- Non-linear, dependency-graph versioning with support for branches, multiple roots, and merge points
- Batch (move-and-copy) migrations that bring SQLite’s limited ALTER support into the fold
- The ability to render migrations to plain SQL scripts for offline or DBA-controlled deployments
Common Use Cases
- Evolving a production database schema safely across application releases
- Autogenerating migration scaffolding from changed SQLAlchemy models to eliminate boilerplate
- Producing SQL migration scripts for environments where direct DDL access is restricted
- Coordinating schema changes across feature branches using merge and branch migrations
Under The Hood
Architecture
Alembic layers a CLI front-end over a scriptable migration engine. alembic/config.py exposes a CommandLine class and main() entry point (registered as the alembic console script) that parse arguments into a Config object and dispatch to functions in alembic/command.py (revision, upgrade, downgrade, stamp). Those commands load a ScriptDirectory (the on-disk migration graph) and an EnvironmentContext/MigrationContext from the project’s generated env.py, which establishes database connectivity. Schema changes are expressed through the op proxy (alembic/op.py, alembic/operations/) that builds minimalist DDL constructs on top of SQLAlchemy’s DDLElement, while alembic/autogenerate/ inspects the live schema and diffs it against model metadata to render candidate scripts via Mako templates.
Tech Stack
Pure Python (targeting 3.10+) with SQLAlchemy (>=1.4.23) as the core schema-inspection and DDL engine, Mako for migration-script templating, and typing-extensions for typing support. The package ships py.typed and .pyi stubs (op.pyi, context.pyi) for full type coverage. Build tooling uses setuptools; development uses nox (noxfile.py), tox, pytest with pytest-xdist, and a comprehensive flake8 lint suite.
Code Quality
The repository is mature and disciplined: 35 test modules under tests/, an inline type-checked codebase (py.typed, stub files, mypy configuration), and an extensive flake8/pydocstyle/import-order lint stack. As part of the SQLAlchemy project it follows the same rigorous coding standards, with production-stable classifiers and a long, consistent release history.
API Design
The developer experience is strong. Migration scripts read declaratively thanks to the op API, where operations like op.add_column() or op.rename_table() are single, self-documenting calls. The CLI mirrors familiar DVCS concepts (revisions identified by UUID-like hashes, branches, merges), and alembic init scaffolds a working environment from selectable templates. Documentation at alembic.sqlalchemy.org is thorough, though the underlying migration concepts carry an inherent learning curve.
Used by 27 apps in this directory
OpenHands
AI Code Assistants · AI Development
The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.
otari
AI Development · Developer Tools
A self-hosted, OpenAI-compatible LLM gateway that puts one endpoint in front of 40+ providers, with virtual API keys, per-user budgets enforced before spend, and full usage tracking.
Arize Phoenix
Analytics · Devops · Monitoring
Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.
Polar
Developer Tools · Ecommerce · Invoicing Finance
Open source payments infrastructure that turns software into a business — subscriptions, usage-based billing, digital products, and merchant-of-record compliance in one platform.
Skyvern
AI Agents · Automation
Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.
SurfSense
AI Assistants · Search
The open-source, unlimited NotebookLM alternative with real-time collaboration, a desktop app, and no vendor lock-in.
Tracecat
AI Agents · Automation · Security
Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.
Voicebox
AI Development · Productivity · Voice AI
Clone voices, dictate anywhere, and give AI agents your voice — all locally.
VoiceStudio
Mcp · Music Audio · Voice AI
Open-source, fully local ElevenLabs alternative for voice cloning, voice design, video dubbing, dictation, transcription and audiobooks, with a local API and MCP server for agents.