Files
notifications-api/migrations/versions/0353_broadcast_provider_not_null.py
Katie Smith 4624328c36 Make service_broadcast_settings.provider non-nullable
We set all existing null values to "all", then make the column
non-nullable. Admin is already passing through the value of "all".
2021-05-10 15:59:22 +01:00

23 lines
715 B
Python

"""
Revision ID: 0353_broadcast_provider_not_null
Revises: 0352_broadcast_provider_types
Create Date: 2021-05-10 15:06:40.046786
"""
from alembic import op
import sqlalchemy as sa
revision = '0353_broadcast_provider_not_null'
down_revision = '0352_broadcast_provider_types'
def upgrade():
op.execute("UPDATE service_broadcast_settings SET provider = 'all' WHERE provider is null")
op.alter_column('service_broadcast_settings', 'provider', existing_type=sa.VARCHAR(), nullable=False)
def downgrade():
op.alter_column('service_broadcast_settings', 'provider', existing_type=sa.VARCHAR(), nullable=True)
op.execute("UPDATE service_broadcast_settings SET provider = null WHERE provider = 'all'")