HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

alembic — Database migration tool for SQLAlchemy. More information: <https://manned.org/alembic>.

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandsqlalchemyalembicdatabaseclimigrationtoolfor

Problem

How to use the alembic command: Database migration tool for SQLAlchemy. More information: <https://manned.org/alembic>.

Solution

alembic — Database migration tool for SQLAlchemy. More information: <https://manned.org/alembic>.

Initialize Alembic in a project:
alembic init {{path/to/directory}}


Create a new migration script with autogeneration:
alembic revision --autogenerate -m "{{message}}"


Upgrade the database to the latest revision:
alembic upgrade head


Downgrade the database by one revision:
alembic downgrade -1


Show the migration history:
alembic history

Code Snippets

Initialize Alembic in a project

alembic init {{path/to/directory}}

Create a new migration script with autogeneration

alembic revision --autogenerate -m "{{message}}"

Upgrade the database to the latest revision

alembic upgrade head

Downgrade the database by one revision

alembic downgrade -1

Show the migration history

alembic history

Context

tldr-pages: common/alembic

Revisions (0)

No revisions yet.