Alembic is a tool for managing database migrations, essential for version-controlled schema changes. Initialize Alembic using `alembic init alembic`. Configure the database URL within the `alembic.ini` file. Create new migration scripts automatically using `alembic revision --autogenerate -m "description"`. Apply migrations to the database with `alembic upgrade head`. Revert migrations using `alembic downgrade -1` or specify a target revision. View the current database revision with `alembic current` and the migration history using `alembic history`. Inspect detailed information about a specific migration using `alembic show`. Stamp the database to a specific revision without running migrations with `alembic stamp head`. The alembic folder contains versions, `env.py`, and `alembic.ini` files. For async users, `env.py` requires modification for asyncpg and async SQLAlchemy compatibility.
dev.to
dev.to
Create attached notes ...
