Alembic

Database migrations tool for SQLAlchemy with autogenerate and transactional DDL

Tool
PyPI
v1.20.1
4,456 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
90 /100 Excellent
Development Activity 96
Maintenance 100
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
88 /100 Excellent
Architecture 88
Code Quality 90
Innovation 87
Learning Curve 80

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

Python
66%
MIT

Flowfile

Data Engineering

398

Visual ETL that compiles to Polars — build pipelines on a canvas, export as standalone Python, and run anywhere without platform lock-in.

View details
83
Repo Health
81
Technical
66
Dependency
Built with
Python 66%
TypeScript 17%
Vue 16%
Updated 1 weeks ago
TypeScript
53%
Apache 2.0

Flowsint

Automation · Developer Tools

9,911

A privacy-first, graph-based OSINT investigation platform with 30+ automated enrichers for mapping relationships between domains, IPs, people, and organizations.

View details
85
Repo Health
71
Technical
67
Dependency
Built with
TypeScript 53%
Python 45%
Updated 1 weeks ago
TypeScript
51%
AGPL 3.0

Glean

Bookmarks Archiving · Knowledge Management

872

Self-hosted RSS reader and personal knowledge management tool with MCP server integration for AI assistant connectivity.

View details
73
Repo Health
75
Technical
70
Dependency
Built with
TypeScript 51%
Python 45%
Updated 1 weeks ago
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,433

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
88
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 1 weeks ago
Python
94%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,755

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
66
Dependency
Built with
Python 94%
Updated 6 days ago
Python
71%
MIT

Langflow

AI Agents · AI Development

155,973

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
64
Dependency
Built with
Python 71%
TypeScript 21%
Updated 6 days ago
Python
53%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,413

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
65
Dependency
Built with
Python 53%
TypeScript 45%
Updated 6 days ago
Python
58%
Apache 2.0

MLflow

AI Development · Monitoring

28,512

The open source AI engineering platform for debugging, evaluating, monitoring, and optimizing production LLMs and agents at scale.

View details
96
Repo Health
86
Technical
67
Dependency
Built with
Python 58%
TypeScript 35%
Updated 6 days ago
Python
38%
Other

Open WebUI

AI Agents · AI Assistants

156,607

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
92
Repo Health
75
Technical
66
Dependency
Built with
Python 38%
Svelte 35%
JavaScript 19%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers