mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-12 00:02:36 -05:00
When we have a public API there will be no human creating the broadcast message. Instead it will be created by an API integration, authenticated by a key (just like for emails or texts). This updates the database to: - add a new foreign key from BroadcastMessages to API keys - add a `reference` column It doesn’t change the model yet, because the model is used by previous migrations, so would cause them to fail when run before the new columns exist. We can make this change in later pull requests.
27 lines
875 B
Python
27 lines
875 B
Python
"""
|
|
|
|
Revision ID: 0337_broadcast_msg_api
|
|
Revises: 0336_broadcast_msg_content_2
|
|
Create Date: 2020-12-04 15:06:22.544803
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
revision = '0337_broadcast_msg_api'
|
|
down_revision = '0336_broadcast_msg_content_2'
|
|
|
|
|
|
def upgrade():
|
|
op.alter_column('broadcast_message', 'created_by_id', nullable=True)
|
|
op.add_column('broadcast_message', sa.Column('api_key_id', postgresql.UUID(), nullable=True))
|
|
op.create_foreign_key(None, 'broadcast_message', 'api_keys', ['api_key_id'], ['id'])
|
|
op.add_column('broadcast_message', sa.Column('reference', sa.String(length=255), nullable=True))
|
|
|
|
|
|
def downgrade():
|
|
op.alter_column('broadcast_message', 'created_by_id', nullable=False)
|
|
op.drop_column('broadcast_message', 'api_key_id')
|
|
op.add_column('broadcast_message', 'reference')
|