From 6d47d97bc0b1dc31befd6d9af532a272da3c9897 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 27 Apr 2022 15:37:46 +0100 Subject: [PATCH] add revision to fix apr rate this will update about 80-90k rows in ft billing --- .../versions/0370_fix_apr_2022_sms_rate.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 migrations/versions/0370_fix_apr_2022_sms_rate.py diff --git a/migrations/versions/0370_fix_apr_2022_sms_rate.py b/migrations/versions/0370_fix_apr_2022_sms_rate.py new file mode 100644 index 000000000..411986943 --- /dev/null +++ b/migrations/versions/0370_fix_apr_2022_sms_rate.py @@ -0,0 +1,34 @@ +""" + +Revision ID: 0370_fix_apr_2022_sms_rate +Revises: 0369_update_sms_rates +Create Date: 2022-04-26 09:39:45.260951 + +""" +import uuid + +from alembic import op + +revision = '0370_fix_apr_2022_sms_rate' +down_revision = '0369_update_sms_rates' + + +def upgrade(): + op.execute( + "INSERT INTO rates(id, valid_from, rate, notification_type) " + f"VALUES('{uuid.uuid4()}', '2022-03-31 23:00:00', 0.0161, 'sms')" + ) + op.execute( + """ + UPDATE ft_billing + SET rate = 0.0161 + WHERE + notification_type = 'sms' AND + bst_date >= '2022-04-01' AND + bst_date < '2022-05-01' + """ + ) + + +def downgrade(): + pass