diff --git a/app/models.py b/app/models.py index cf58a6867..5df7730bf 100644 --- a/app/models.py +++ b/app/models.py @@ -1193,7 +1193,7 @@ class Notification(db.Model): postage = db.Column(db.String, nullable=True) CheckConstraint(""" CASE WHEN notification_type = 'letter' THEN - postage in ('first', 'second') + postage is not null and postage in ('first', 'second') ELSE postage is null END @@ -1453,7 +1453,7 @@ class NotificationHistory(db.Model, HistoryModel): postage = db.Column(db.String, nullable=True) CheckConstraint(""" CASE WHEN notification_type = 'letter' THEN - postage in ('first', 'second') + postage is not null and postage in ('first', 'second') ELSE postage is null END diff --git a/migrations/versions/0230_noti_postage_constraint.py b/migrations/versions/0230_noti_postage_constraint.py index 118d51b39..a8c40d7ec 100644 --- a/migrations/versions/0230_noti_postage_constraint.py +++ b/migrations/versions/0230_noti_postage_constraint.py @@ -17,7 +17,7 @@ def upgrade(): ALTER TABLE notifications ADD CONSTRAINT "chk_notifications_postage_null" CHECK ( CASE WHEN notification_type = 'letter' THEN - postage in ('first', 'second') + postage is not null and postage in ('first', 'second') ELSE postage is null END @@ -28,7 +28,7 @@ def upgrade(): ALTER TABLE notification_history ADD CONSTRAINT "chk_notification_history_postage_null" CHECK ( CASE WHEN notification_type = 'letter' THEN - postage in ('first', 'second') + postage is not null and postage in ('first', 'second') ELSE postage is null END