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".
This commit is contained in:
Katie Smith
2021-05-10 15:41:34 +01:00
parent 96cb30d640
commit 4624328c36
4 changed files with 41 additions and 28 deletions

View File

@@ -0,0 +1,22 @@
"""
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'")