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:
Leo Hemsted
2020-10-26 16:04:39 +00:00
parent 3aa602bd6b
commit 2e665de46d
2 changed files with 95 additions and 1 deletions

View 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')