mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-14 01:02:09 -05:00
We need to deal with this, it's ok when updating a notification status from delivered to delivered. But the DailySortedLetter counts are being doubled. Adding the file_name to the table as a unique key to get around this issue. It will mean we have multiple rows for each billing_day, but that's ok we can aggregate that. This will also give us a way to see which file created which count.
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
"""
|
|
|
|
Revision ID: 0178_add_filename
|
|
Revises: 0177_add_virus_scan_statuses
|
|
Create Date: 2018-03-14 16:15:01.886998
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = '0178_add_filename'
|
|
down_revision = '0177_add_virus_scan_statuses'
|
|
|
|
|
|
def upgrade():
|
|
op.add_column('daily_sorted_letter', sa.Column('file_name', sa.String(), nullable=True))
|
|
op.create_index(op.f('ix_daily_sorted_letter_file_name'), 'daily_sorted_letter', ['file_name'], unique=False)
|
|
op.create_unique_constraint('uix_file_name_billing_day', 'daily_sorted_letter', ['file_name', 'billing_day'])
|
|
op.drop_index('ix_daily_sorted_letter_billing_day', table_name='daily_sorted_letter')
|
|
op.create_index(op.f('ix_daily_sorted_letter_billing_day'), 'daily_sorted_letter', ['billing_day'], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_daily_sorted_letter_billing_day'), table_name='daily_sorted_letter')
|
|
op.create_index('ix_daily_sorted_letter_billing_day', 'daily_sorted_letter', ['billing_day'], unique=True)
|
|
op.drop_constraint('uix_file_name_billing_day', 'daily_sorted_letter', type_='unique')
|
|
op.drop_index(op.f('ix_daily_sorted_letter_file_name'), table_name='daily_sorted_letter')
|
|
op.drop_column('daily_sorted_letter', 'file_name')
|