Add unique constraint to email branding domains

Does two things:

1. Revert "Revert "Add unique constraint to email branding domain""

This reverts commit af9cb30ef3.

2. Don’t allow empty string in email branding domain

Columns with multiple `null`s can have a uniqueness constraint. Columns
with multiple empty string values are not considered unique.

This commit:
- removes any duplicate empty string values
- casts empty strings to null string any time these columns are updated

---

Squashed into this single commits because these two things are not
atomic as individual commits.
This commit is contained in:
Chris Hill-Scott
2018-09-04 10:57:47 +01:00
parent 55b7b3b157
commit 5d5047fb13
4 changed files with 42 additions and 2 deletions

View File

@@ -23,5 +23,5 @@ def dao_create_email_branding(email_branding):
@transactional
def dao_update_email_branding(email_branding, **kwargs):
for key, value in kwargs.items():
setattr(email_branding, key, value)
setattr(email_branding, key, value or None)
db.session.add(email_branding)