Skip to content

Dev_Database Migrations

Adrien Pavão edited this page Mar 31, 2022 · 3 revisions

The CodaLab project uses South (South Docs) for migrations.

When changes are made to the models a migration will need to be created to capture the change and allow it to be applied. In the simplest case, such as adding fields and tables:

./manage schemamigration APPNAME --auto

To apply the migration:

./manage migrate

The migration created is a python script which is executed when migrate is run. It can be edited if necessary. The structure is not complex, but some skill with SQL may be required if the migration represents invasive changes to a schema which might add or move data between tables, for instance.

Testing Migrations

The safest option is to make a copy/clone/snapshot of the database representing the state of the models before changes are made, making the changes and testing the application of the migration.

IMPORTANT: It is the responsibility of both testers and developers to test and validate a migration as the nature of what they are can destroy data permanently.

2022 update

Use this to perform migration:

docker-compose up -d
docker-compose exec django bash
python3 manage.py makemigrations
python3 manage.py migrate
Clone this wiki locally