mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 14:08:47 -04:00
update notification_history table from notification_dao create/update functions
please ensure that any changes to notifications table happen through either dao_create_notification or dao_update_notification. changed the notification status update triggered by the provider callbacks to ensure that sets updated_by and can update the history table. also re-added the character_count so we can reconstruct billing data if needed.
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 807f0b497157
|
||||
Revises: 0041_notification_history
|
||||
Create Date: 2016-07-07 13:15:35.503107
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0040_adjust_mmg_provider_rate'
|
||||
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 ###
|
||||
61
migrations/versions/0042_notification_history.py
Normal file
61
migrations/versions/0042_notification_history.py
Normal file
@@ -0,0 +1,61 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0042_notification_history
|
||||
Revises: 0041_email_template
|
||||
Create Date: 2016-07-07 13:15:35.503107
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0042_notification_history'
|
||||
down_revision = '0041_email_template'
|
||||
|
||||
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('content_char_count', sa.Integer(), nullable=True),
|
||||
sa.Column('notification_type', postgresql.ENUM('email', 'sms', 'letter', name='notification_type', create_type=False), 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', postgresql.ENUM('created', 'sending', 'delivered', 'pending', 'failed', 'technical-failure', 'temporary-failure', 'permanent-failure', name='notify_status_type', create_type=False), 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