alembic(1)
lightweight database migration tool for usage with the SQLAlchemy
Summary
alembic is a lightweight database migration tool for SQLAlchemy, used to version-control your database schema and apply incremental changes over time. You generate revision scripts that describe schema changes, then upgrade or downgrade a database between those versions. It's the standard way to evolve a database schema alongside a Python application's code.
Description
ALEMBIC
NAME
alembic - lightweight database migration tool for usage with the SQLAlchemy
DESCRIPTION
usage: alembic [-h] [-c CONFIG] [-n NAME] [-x X] [--raiseerr]
{branches, current, downgrade, edit, heads, history, init, list_templates, merge, revision, show, stamp, upgrade} ...
positional arguments:
{branches, current, downgrade, edit, heads, history, init, list_templates, merge, revision, show, stamp, upgrade}
branches
Show current branch points
current
Display the current revision for a database.
downgrade
Revert to a previous version.
|
edit |
Edit revision script(s) using $EDITOR |
|||
|
heads |
Show current available heads in the script directory |
history
List changeset scripts in chronological order.
|
init |
Initialize a new scripts directory. |
list_templates
List available templates
|
merge |
Merge two revisions together. Creates a new migration file. .. versionadded:: 0.7.0 .. seealso:: :ref:‘branches‘ |
revision
Create a new revision file.
|
show |
Show the revision(s) denoted by the given symbol. | ||
|
stamp |
’stamp’ the revision table with the given revision; don’t run any migrations. |
upgrade
Upgrade to a later version.
optional arguments:
-h, --help
show this help message and exit
-c CONFIG, --config CONFIG
Alternate config file
-n NAME, --name NAME
Name of section in .ini file to use for Alembic config
|
-x X |
Additional arguments consumed by custom env.py scripts, e.g. -x setting1=somesetting -x setting2=somesetting |
--raiseerr
Raise a full stack trace on error
Examples
alembic init alembic
Initialize a new migration scripts directory in your project.
alembic revision -m "add users table"
Create a new revision file describing a schema change.
alembic upgrade head
Apply migrations to bring the database up to the latest version.
alembic downgrade -1
Revert the database to the previous version.