Add command to populate the free_sms_fragment_limit

Added a one-off command to set values of the free_sms_fragment_limit in
the services table and the services_history table to the default of
250000.
This commit is contained in:
Katie Smith
2017-10-11 14:00:53 +01:00
parent 2001bfca36
commit 9322ed0ca3
2 changed files with 26 additions and 0 deletions

View File

@@ -305,3 +305,27 @@ class PopulateServiceLetterContact(Command):
db.session.commit()
print("Populated letter contacts for {} services".format(result.rowcount))
class PopulateServiceAndServiceHistoryFreeSmsFragmentLimit(Command):
def run(self):
services_to_update = """
UPDATE services
SET free_sms_fragment_limit = 250000
WHERE free_sms_fragment_limit IS NULL
"""
services_history_to_update = """
UPDATE services_history
SET free_sms_fragment_limit = 250000
WHERE free_sms_fragment_limit IS NULL
"""
services_result = db.session.execute(services_to_update)
services_history_result = db.session.execute(services_history_to_update)
db.session.commit()
print("Populated free sms fragment limits for {} services".format(services_result.rowcount))
print("Populated free sms fragment limits for {} services history".format(services_history_result.rowcount))