mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-04 17:53:57 -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.