Add unique key on annual_billing for service_id + financial_year_start.

This is an extra precaution for the table to ensure data integrity. Since we only update/insert the data using the annual_billing_dao methods the integrity is in tact. I've check the data on preview, staging and prod there are no violations of this unique key.
This commit is contained in:
Rebecca Law
2021-04-20 13:42:20 +01:00
parent bcd1939179
commit a637c8eb92
3 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
"""
Revision ID: 0351_unique_key_annual_billing
Revises: 0350_update_rates
Create Date: 2021-04-12 09:02:45.098875
"""
from alembic import op
revision = '0351_unique_key_annual_billing'
down_revision = '0350_update_rates'
def upgrade():
op.create_unique_constraint(
'uix_service_id_financial_year_start', 'annual_billing', ['service_id', 'financial_year_start']
)
def downgrade():
op.drop_constraint('uix_service_id_financial_year_start', 'annual_billing', type_='unique')