mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:15:19 -05:00
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:
28
migrations/versions/0223_add_domain_constraint.py
Normal file
28
migrations/versions/0223_add_domain_constraint.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
Revision ID: 0223_add_domain_constraint
|
||||
Revises: 0222_drop_service_branding
|
||||
Create Date: 2018-08-24 13:36:49.346156
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
|
||||
revision = '0223_add_domain_constraint'
|
||||
down_revision = '0222_drop_service_branding'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
op.execute("""
|
||||
update
|
||||
email_branding
|
||||
set
|
||||
domain = null
|
||||
where
|
||||
domain = ''
|
||||
""")
|
||||
op.create_unique_constraint('uq_email_branding_domain', 'email_branding', ['domain'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
op.drop_constraint('uq_email_branding_domain', 'email_branding')
|
||||
Reference in New Issue
Block a user