mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-10 23:32:27 -05:00
If is_letter_contact_blank then the user has set the letter contact block to be blank on purpose ELSE IF is_letter_contact_blank is false THEN use the template default IF template default is blank THEN the service_letter_contact is blank use the service default
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""
|
|
|
|
Revision ID: ea1c2f80a50e
|
|
Revises: 0152_kill_service_free_fragments
|
|
Create Date: 2018-01-04 10:27:01.014640
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = '0153_add_is_letter_contact_blank'
|
|
down_revision = '0152_kill_service_free_fragments'
|
|
|
|
|
|
def upgrade():
|
|
op.add_column('templates', sa.Column('is_letter_contact_blank', sa.Boolean(), nullable=True))
|
|
op.add_column('templates_history', sa.Column('is_letter_contact_blank', sa.Boolean(), nullable=True))
|
|
op.execute("update templates set is_letter_contact_blank = false")
|
|
op.execute("update templates_history set is_letter_contact_blank = false")
|
|
op.alter_column("templates", "is_letter_contact_blank", nullable=False)
|
|
op.alter_column("templates_history", "is_letter_contact_blank", nullable=False)
|
|
|
|
op.create_check_constraint(
|
|
"ck_templates_contact_block_is_blank",
|
|
"templates",
|
|
"Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)"
|
|
)
|
|
op.create_check_constraint(
|
|
"ck_templates_history_contact_block_is_blank",
|
|
"templates_history",
|
|
"Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)"
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_column('templates_history', 'is_letter_contact_blank')
|
|
op.drop_column('templates', 'is_letter_contact_blank')
|