Files
notifications-api/migrations/versions/0221_nullable_service_branding.py

67 lines
1.5 KiB
Python
Raw Normal View History

"""
Revision ID: 0221_nullable_service_branding
Revises: 0220_email_brand_type_non_null
Create Date: 2018-08-24 13:36:49.346156
"""
from alembic import op
2023-08-29 14:54:30 -07:00
revision = "0221_nullable_service_branding"
down_revision = "0220_email_brand_type_non_null"
def upgrade():
2023-08-29 14:54:30 -07:00
op.drop_constraint("services_branding_fkey", "services", type_="foreignkey")
2023-08-29 14:54:30 -07:00
op.drop_index("ix_services_history_branding", table_name="services_history")
op.drop_index("ix_services_branding", table_name="services")
2023-08-29 14:54:30 -07:00
op.alter_column("services_history", "branding", nullable=True)
op.alter_column("services", "branding", nullable=True)
2023-08-29 14:54:30 -07:00
op.execute(
"""
update
email_branding
set
2023-07-17 13:16:50 -07:00
brand_type = 'org'
where
2023-07-17 13:16:50 -07:00
brand_type = 'govuk'
2023-08-29 14:54:30 -07:00
"""
)
2023-08-29 14:54:30 -07:00
op.execute(
"""
delete from
branding_type
where
2023-07-17 13:16:50 -07:00
name = 'govuk'
2023-08-29 14:54:30 -07:00
"""
)
def downgrade():
2023-08-29 14:54:30 -07:00
op.create_index(
op.f("ix_services_branding"), "services", ["branding"], unique=False
)
op.create_index(
op.f("ix_services_history_branding"),
"services_history",
["branding"],
unique=False,
)
2023-08-29 14:54:30 -07:00
op.create_foreign_key(None, "services", "branding_type", ["branding"], ["name"])
2023-08-29 14:54:30 -07:00
op.alter_column("services", "branding", nullable=False)
op.alter_column("services_history", "branding", nullable=False)
2023-08-29 14:54:30 -07:00
op.execute(
"""
insert into
branding_type
(name)
values
2023-07-17 13:16:50 -07:00
('govuk')
2023-08-29 14:54:30 -07:00
"""
)