mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-08 22:22:24 -05:00
Add DB table for service broadcast settings
This will allow us to store details of which channel a service should be sending to. See the comment about how all broadcast services can have a row in the table but may not at the moment. This has been done for speed as it's the quickest way to let us set up different services to send to different channels for some needed testing with the mobile handset providers in the coming week.
This commit is contained in:
43
migrations/versions/0342_service_broadcast_settings.py
Normal file
43
migrations/versions/0342_service_broadcast_settings.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0342_service_broadcast_settings
|
||||
Revises: 0341_new_letter_rates
|
||||
Create Date: 2021-01-28 21:30:23.102340
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0342_service_broadcast_settings'
|
||||
down_revision = '0341_new_letter_rates'
|
||||
|
||||
CHANNEL_TYPES = ["test", "severe"]
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('broadcast_channel_types',
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint('name')
|
||||
)
|
||||
op.create_table('service_broadcast_settings',
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('channel', sa.String(length=255), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['channel'], ['broadcast_channel_types.name'], ),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('service_id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
for channel in CHANNEL_TYPES:
|
||||
op.execute(f"INSERT INTO broadcast_channel_types VALUES ('{channel}')")
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('service_broadcast_settings')
|
||||
op.drop_table('broadcast_channel_types')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user