DEV.co
Open-Source Databases · sqlalchemy

alembic

Alembic is a database migration tool for Python applications using SQLAlchemy. It automates schema changes, supports version control-like workflows for migrations, and works across multiple databases including SQLite, PostgreSQL, and SQL Server.

Source: GitHub — github.com/sqlalchemy/alembic
4.2k
GitHub stars
348
Forks
Python
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorysqlalchemy/alembic
Ownersqlalchemy
Primary languagePython
LicenseMIT — OSI-approved
Stars4.2k
Forks348
Open issues121
Latest releaserel_1_18_5 (2026-06-25)
Last updated2026-06-30
Sourcehttps://github.com/sqlalchemy/alembic

What alembic is

Alembic provides declarative and imperative migration scripts, auto-generation of schema diffs, transactional DDL support, non-linear dependency graphs for complex branching scenarios, and DDL constructs compatible with SQLAlchemy ORM. It generates Python or raw SQL migration files and includes batch mode for SQLite ALTER limitations.

Quickstart

Get the alembic source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/sqlalchemy/alembic.gitcd alembic# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Managed Production Database Evolution

Organizations requiring auditability, reversibility, and transactional safety for schema changes. Alembic's explicit migration versioning and downgrade support suit regulated environments and teams using version control for DDL.

Multi-Database Deployment Workflows

Applications spanning PostgreSQL, MySQL, SQL Server, SQLite, and Oracle. Alembic abstracts database-specific DDL differences and generates appropriate SQL per target dialect.

Agile Development with Schema Auto-Generation

Fast-moving teams using SQLAlchemy ORM models as the source of truth. The --autogenerate flag reduces boilerplate for detecting and suggesting schema changes, though manual review remains necessary.

Implementation considerations

  • Alembic requires SQLAlchemy ORM or Core integration; ensure your data models are defined in SQLAlchemy before initializing migrations.
  • Auto-generation detects schema changes but does not replace developer review; many real-world migrations require custom data transformations and logic.
  • For transactional DDL, verify database support (PostgreSQL, SQL Server); MySQL and SQLite have limitations that affect rollback behavior.
  • Batch mode must be explicitly enabled for SQLite; teams supporting SQLite should test batch migration workflows early.
  • Non-linear versioning (branching, merges) provides flexibility but can introduce operational complexity if not governed by clear team conventions.

When to avoid it — and what to weigh

  • Non-SQLAlchemy Projects — Alembic is tightly coupled to SQLAlchemy. Use alternative tools if your data layer does not use SQLAlchemy ORM or Core.
  • Real-Time Schema Inference Required — Alembic assumes explicit migration files. Projects needing zero-downtime rolling migrations without explicit versioning may require additional tooling or orchestration.
  • Schema Complexity Beyond DDL — Data-heavy migrations or cross-schema dependencies require custom Python logic. For systems with extensive procedural logic, manual scripting overhead increases.
  • No Database Access During Deployment — Script-only output mode helps but does not eliminate the need for eventual database connectivity. Environments requiring fully offline schema deployment may face operational friction.

License & commercial use

Alembic is distributed under the MIT License, a permissive OSI-approved license. MIT permits commercial use, modification, and distribution with minimal restrictions (retain copyright and license notice).

MIT license permits commercial use without royalties. No known commercial restrictions or dual-licensing. Review the LICENSE file in the repository for exact terms and ensure your legal team approves use in your commercial product.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

Alembic scripts execute arbitrary Python and SQL; treat migration files as code subject to review and version control. Ensure database credentials are not hardcoded in alembic.ini or scripts; use environment variables or secrets management. Audit trail depends on your database and application logging. No known CVEs in available data, but review dependencies (SQLAlchemy) for known vulnerabilities.

Alternatives to consider

Flyway

Language-agnostic, Java-based, strong support for multiple databases and zero-downtime deployments. Better suited for teams not using SQLAlchemy or requiring a standalone tool.

Liquibase

XML/YAML-driven migrations, broad database support, strong in enterprise environments. Higher overhead but greater tool-driven validation. Lacks tight ORM integration.

Django Migrations

Built into Django ORM; simpler for Django projects. Alembic is superior for standalone SQLAlchemy apps or non-Django frameworks.

Software development agency

Build on alembic with DEV.co software developers

Our engineers can design migration strategies, optimize CI/CD workflows, and ensure schema safety across your environments. Let's talk.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

alembic FAQ

Can I use Alembic without SQLAlchemy ORM?
Alembic can work with SQLAlchemy Core (lower-level SQL abstraction), but not without SQLAlchemy entirely. It relies on SQLAlchemy's reflection and DDL capabilities.
Does Alembic auto-generate all my migrations?
No. The --autogenerate flag detects schema changes (columns, constraints, indexes) and generates candidate migration scripts. You must review and often edit them to add data migrations, custom logic, or handle complex scenarios.
Can I rollback a migration if something goes wrong?
Alembic supports downgrade scripts if the database supports transactional DDL (PostgreSQL, SQL Server). SQLite and MySQL have limitations. Always test downgrades in non-prod environments.
How do I handle multiple database targets in a single codebase?
Use Alembic's environment configuration and SQL compilation features to generate dialect-specific SQL. Test migrations against each target database before deployment.

Software developers & web developers for hire

DEV.co helps companies turn open-source tools like alembic into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source databases stack.

Need Help Integrating Alembic into Your Stack?

Our engineers can design migration strategies, optimize CI/CD workflows, and ensure schema safety across your environments. Let's talk.