mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-11 08:23:53 -04:00
Removes notifications.template_id foreign key and replaces it with a composite foreign key constraint to TemplateHistory using the existing notification columns for template ID and template version. Foreign key constraint is created as NOT VALID to avoid locking the notifications table while postgres verifies that existing records don't break the constraint. From postgres docs: > If the constraint is marked NOT VALID, the potentially-lengthy initial > check to verify that all rows in the table satisfy the constraint is > skipped. The constraint will still be enforced against subsequent > inserts or updates (that is, they'll fail unless there is a matching > row in the referenced table, in the case of foreign keys; and they'll > fail unless the new row matches the specified check constraints). But > the database will not assume that the constraint holds for all rows > in the table, until it is validated by using the VALIDATE CONSTRAINT > option. VALIDATE CONSTRAINT will be issued as a separate migration in a follow-up PR.
Generic single-database configuration. python application.py db migrate to generate migration script. python application.py db upgrade to upgrade db with script. python application.py db downgrade to rollback db changes. python application.py db current to show current script.