mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
add notification_history table
table will be used for storing archival versions of notifications. It's an exact duplicate of notifications table, but with the following modifications: * removed _personalisation * removed to * removed content_char_count All foreign keys to other tables still exist. additionally, removed defaults (for id and created_at) since they'll be set when we create, and we should ensure that we don't forget about them when inserting/udpating this table.
This commit is contained in:
60
migrations/versions/0041_notification_history.py
Normal file
60
migrations/versions/0041_notification_history.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 807f0b497157
|
||||
Revises: 0039_fix_notifications
|
||||
Create Date: 2016-07-07 13:15:35.503107
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '807f0b497157'
|
||||
down_revision = '0039_fix_notifications'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('notification_history',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('job_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('job_row_number', sa.Integer(), nullable=True),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('template_version', sa.Integer(), nullable=False),
|
||||
sa.Column('api_key_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('key_type', sa.String(), nullable=False),
|
||||
sa.Column('notification_type', sa.Enum('email', 'sms', 'letter', name='notification_type'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('sent_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('sent_by', sa.String(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('status', sa.Enum('created', 'sending', 'delivered', 'pending', 'failed', 'technical-failure', 'temporary-failure', 'permanent-failure', name='notify_status_type'), nullable=False),
|
||||
sa.Column('reference', sa.String(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['api_key_id'], ['api_keys.id'], ),
|
||||
sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], ),
|
||||
sa.ForeignKeyConstraint(['key_type'], ['key_types.name'], ),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_notification_history_api_key_id'), 'notification_history', ['api_key_id'], unique=False)
|
||||
op.create_index(op.f('ix_notification_history_job_id'), 'notification_history', ['job_id'], unique=False)
|
||||
op.create_index(op.f('ix_notification_history_key_type'), 'notification_history', ['key_type'], unique=False)
|
||||
op.create_index(op.f('ix_notification_history_reference'), 'notification_history', ['reference'], unique=False)
|
||||
op.create_index(op.f('ix_notification_history_service_id'), 'notification_history', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_notification_history_template_id'), 'notification_history', ['template_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_notification_history_template_id'), table_name='notification_history')
|
||||
op.drop_index(op.f('ix_notification_history_service_id'), table_name='notification_history')
|
||||
op.drop_index(op.f('ix_notification_history_reference'), table_name='notification_history')
|
||||
op.drop_index(op.f('ix_notification_history_key_type'), table_name='notification_history')
|
||||
op.drop_index(op.f('ix_notification_history_job_id'), table_name='notification_history')
|
||||
op.drop_index(op.f('ix_notification_history_api_key_id'), table_name='notification_history')
|
||||
op.drop_table('notification_history')
|
||||
### end Alembic commands ###
|
||||
Reference in New Issue
Block a user