mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-02 07:10:14 -04:00
Allow broadcast messages to be created with API key
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.
This commit is contained in:
26
migrations/versions/0337_broadcast_msg_api.py
Normal file
26
migrations/versions/0337_broadcast_msg_api.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
|
||||
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')
|
||||
Reference in New Issue
Block a user