Alembic Database Migrations
v1.18 — 2026 Edition. Master database migrations with Alembic 1.18 in Python. Learn how to manage schema changes, use autogenerate, handle constraints, write offline scripts, and orchestrate database migrations effectively alongside SQLAlchemy.
Episodes
The Case for Migrations
3m 09sDiscover why manual schema management fails at scale and how Alembic brings version control to your relational database. We explore the core mental model of database migrations and break down the anatomy of the Alembic environment.
Anatomy of a Revision
3m 45sWalk through the lifecycle of your very first Alembic migration. We break down the upgrade and downgrade functions and reveal how version tracking actually works inside the database.
The Magic and Limits of Autogenerate
3m 21sUncover how Alembic automatically detects changes by comparing your SQLAlchemy models to live database metadata. Learn what it catches flawlessly and what it misses.
The Importance of Naming Constraints
3m 38sDiscover why relying on database-generated names for constraints is a recipe for migration disasters. Learn how to configure a unified naming convention for your system.
Offline Migrations and SQL Generation
4m 05sExplore how to generate pure SQL scripts for your database administrators instead of running Python against your production database directly. We discuss the offline execution flow.
Batch Migrations for SQLite
3m 14sTackle the challenge of altering tables in SQLite, which lacks full ALTER TABLE support. Learn the move and copy workflow using Alembic's batch operations.
Working with Branches
3m 43sMaster team collaboration by handling branched migration streams. Learn how to identify and merge divergent revision histories when multiple developers modify the database.
Production Power-Ups
3m 46sLevel up your Alembic knowledge with advanced techniques. We cover programmatic command invocation and sharing a connection with application frameworks like FastAPI.