mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 07:46:06 -04:00
Add unique constraint to email branding domain
Brandings with a domain set should be considered canonical. It doesn’t make sense to have the same domain set on multiple different email brands – you can’t tell which one to use.
This commit is contained in:
@@ -207,7 +207,7 @@ class EmailBranding(db.Model):
|
|||||||
logo = db.Column(db.String(255), nullable=True)
|
logo = db.Column(db.String(255), nullable=True)
|
||||||
name = db.Column(db.String(255), nullable=True)
|
name = db.Column(db.String(255), nullable=True)
|
||||||
text = db.Column(db.String(255), nullable=True)
|
text = db.Column(db.String(255), nullable=True)
|
||||||
domain = db.Column(db.Text, nullable=True)
|
domain = db.Column(db.Text, unique=True, nullable=True)
|
||||||
brand_type = db.Column(
|
brand_type = db.Column(
|
||||||
db.String(255),
|
db.String(255),
|
||||||
db.ForeignKey('branding_type.name'),
|
db.ForeignKey('branding_type.name'),
|
||||||
|
|||||||
20
migrations/versions/0223_add_domain_constraint.py
Normal file
20
migrations/versions/0223_add_domain_constraint.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"""
|
||||||
|
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.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