Database migrationsΒΆ

Modifying database schemata will need database migrations (even for adding and removing tables). To autogenerate migrations:

$ docker-compose run web python -m warehouse db revision --autogenerate --message "text"

Verify your migration was generated by looking at the output from the command above:

Generating /opt/warehouse/src/warehouse/migrations/versions/390811c1c\ ... done

Then migrate and test your migration:

$ docker-compose run web python -m warehouse db upgrade head

Migrations are automatically run as part of the deployment process, but prior to the old version of Warehouse from being shut down. This means that each migration must be compatible with the current main branch of Warehouse.

This makes it more difficult to make breaking changes, since you must phase them in over time (for example, to rename a column you must add the column in one migration + start writing to that column/reading from both, then you must make a migration that backfills all of the data, then switch the code to stop using the old column all together, then finally you can remove the old column).