mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
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:
@@ -102,7 +102,7 @@ def set_default_free_allowance_for_service(service, year_start=None):
|
||||
f"{default_free_sms_fragment_limits['other'][year_start]}")
|
||||
free_allowance = default_free_sms_fragment_limits['other'][year_start]
|
||||
|
||||
dao_create_or_update_annual_billing_for_year(
|
||||
return dao_create_or_update_annual_billing_for_year(
|
||||
service.id,
|
||||
free_allowance,
|
||||
year_start
|
||||
|
||||
@@ -579,6 +579,9 @@ class AnnualBilling(db.Model):
|
||||
UniqueConstraint('financial_year_start', 'service_id', name='ix_annual_billing_service_id')
|
||||
service = db.relationship(Service, backref=db.backref("annual_billing", uselist=True))
|
||||
|
||||
__table_args__ = (UniqueConstraint(
|
||||
'service_id', 'financial_year_start', name='uix_service_id_financial_year_start'),)
|
||||
|
||||
def serialize_free_sms_items(self):
|
||||
return {
|
||||
'free_sms_fragment_limit': self.free_sms_fragment_limit,
|
||||
|
||||
Reference in New Issue
Block a user