Alembic, migration management

Adarsha Regmi
1 min readSep 6, 2021

--

::

The creation, management and invocation of change management scripts for a relational database, using SQLalchemy as base engine

still confused

eg. If you check Django you can see migrations are created each time we make changes to database.this act is performed by alembic.

Practical guide :: you can check youtube video .

Step 1 : intialize the environment

Command: :

|| alembic init alembic

you must have alembic installed.

structure formed

About the files and directories created << check documentation this is quick guide lol >>

link : https://alembic.sqlalchemy.org/en/latest/tutorial.html

Step 2 :

build revision using command

alembic revision -m “create table for user”

This will create version named similar to 808084654_create_table_for_user.py

Inside this you have upgrade and downgrade method.

Upgrade is used for creating whereas downgrade for removing or dropping

If you want to change things like version path, script location ??

check alembic.ini file

script location: alembic -> . if you have alembic.ini inside alembic

--

--