mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
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:
22
migrations/versions/0353_broadcast_provider_not_null.py
Normal file
22
migrations/versions/0353_broadcast_provider_not_null.py
Normal 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'")
|
||||
Reference in New Issue
Block a user