Skip to content

Files

Latest commit

82ad096 · Dec 14, 2020

History

History
31 lines (20 loc) · 1.05 KB

README.md

File metadata and controls

31 lines (20 loc) · 1.05 KB

Database migration

Generation of migration scripts

Migration scripts are created each time modifications are made on the database model or data.

For example if you want to add a new field to a table, add the column in the SQLAlchemy model.

Create the migration script with:

docker-compose exec api .build/venv/bin/alembic revision -m 'Add column x'

A new migration script is created in alembic_migration/versions/. Add the required database operations to the script (see Operation Reference).

To add the new column to the database, run the migration (see below) and make sure the database is updated correctly.

For replacable objects like functions or views, the method described in documentation is used.

Run a migration

A migration should be run each time the application code is updated or if you have just created a migration script.

docker-compose exec api .build/venv/bin/alembic upgrade head