mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-10 23:32:27 -05:00
The `notifications`, `notification_history`, `templates` and `templates_history` tables all had a check constraint on the postage column which specified that the postage had to be `first` or `second` if the notification or template was a letter. We now have two more options for postage - `europe` and `rest-of-world`. It's not possible to alter a check constraint, so the constraints have to be dropped then recreated. We are not recreating the constraint on the `notification_history` table since values here are always copied from the `notifications` table. The constraints get added as `NOT VALID` at first - this stage will lock the tables, so updating the `notification` table and `templates` and `templates_history` are done in separate migrations so that we don't lock all tables at the same time. In a third migration we then run `VALIDATE CONSTRAINT` for all tables - this will lock a row at a time, not the whole table.
Generic single-database configuration.
flask db migrate to generate migration script.
flask db upgrade to upgrade db with script.
flask db downgrade to rollback db changes.
flask db current to show current script.