Alembic Database Migration Tool

Alembic Database Migration Tool

alembic.sqlalchemy.org

2

About this website

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python, created by SQLAlchemy author Michael Bayer and maintained as part of the SQLAlchemy project. The tool provides a framework for generating and applying schema changes to relational databases in a controlled, versioned manner. Unlike declarative migration tools that auto-detect model changes, Alembic uses an explicit migration scripts approach where each migration is a Python script with upgrade and downgrade functions, giving developers full control over the migration logic. Alembic supports auto-generation of migration scripts by comparing the current database schema against SQLAlchemy model definitions, detecting changes such as new tables, added or removed columns, foreign key modifications, index changes, and constraint additions. The generated scripts serve as starting points that can be manually refined for complex transformations including data migrations alongside schema changes. Alembic supports all databases supported by SQLAlchemy including PostgreSQL, MySQL, SQLite, Oracle, Microsoft SQL Server, and Firebird. The tool maintains a version tracking table in the database to record which migrations have been applied, enabling forward and backward migrations. Alembic supports multiple database environments (development, staging, production) through configuration files, offline migration generation for review, and programmatic API access for embedding in deployment scripts.

Tags & Categories

Statistics

2
Views
0
Clicks
0
Like
0
Dislike

Comments

Log In to post a comment

No comments yet. Be the first!