mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
add broadcast provider message table to DB
we need to track the state of sending to different provider separately (and trigger them off separately, refer to references separately, etc)
This commit is contained in:
49
migrations/versions/0332_broadcast_provider_msg.py
Normal file
49
migrations/versions/0332_broadcast_provider_msg.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0332_broadcast_provider_msg
|
||||
Revises: 0331_add_broadcast_org
|
||||
Create Date: 2020-10-26 16:28:11.917468
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0332_broadcast_provider_msg'
|
||||
down_revision = '0331_add_broadcast_org'
|
||||
|
||||
STATUSES = [
|
||||
'technical-failure',
|
||||
'sending',
|
||||
'returned-ack',
|
||||
'returned-error',
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
broadcast_provider_message_status_type = op.create_table(
|
||||
'broadcast_provider_message_status_type',
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('name')
|
||||
)
|
||||
op.bulk_insert(broadcast_provider_message_status_type, [{'name': status} for status in STATUSES])
|
||||
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'broadcast_provider_message',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('broadcast_event_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('provider', sa.String(), nullable=True),
|
||||
sa.Column('status', sa.String(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['broadcast_event_id'], ['broadcast_event.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('broadcast_event_id', 'provider')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('broadcast_provider_message')
|
||||
op.drop_table('broadcast_provider_message_status_type')
|
||||
Reference in New Issue
Block a user