From 8f211e00f5c7c232d2e88f12f8c817f6f399be95 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Thu, 5 Jul 2018 15:25:40 +0100 Subject: [PATCH] Migration for new letter pricing We now support letters of up to 5 sheets long, so we need to store the rates for 4 and 5 sheet letters (both crown and non-crown) in the `letter_rates` table. --- .../versions/0202_new_letter_pricing.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 migrations/versions/0202_new_letter_pricing.py diff --git a/migrations/versions/0202_new_letter_pricing.py b/migrations/versions/0202_new_letter_pricing.py new file mode 100644 index 000000000..1a6b25f92 --- /dev/null +++ b/migrations/versions/0202_new_letter_pricing.py @@ -0,0 +1,37 @@ +"""empty message + +Revision ID: 0202_new_letter_pricing +Revises: 0201_another_letter_org +Create Date: 2017-07-09 12:44:16.815039 + +""" + +revision = '0202_new_letter_pricing' +down_revision = '0201_another_letter_org' + +import uuid +from datetime import datetime +from alembic import op + + +start = datetime(2018, 6, 30, 23, 0) + +NEW_RATES = [ + (uuid.uuid4(), start, 4, 0.39, True, 'second'), + (uuid.uuid4(), start, 4, 0.51, False, 'second'), + (uuid.uuid4(), start, 5, 0.42, True, 'second'), + (uuid.uuid4(), start, 5, 0.57, False, 'second'), +] + + +def upgrade(): + conn = op.get_bind() + for id, start_date, sheet_count, rate, crown, post_class in NEW_RATES: + conn.execute(""" + INSERT INTO letter_rates (id, start_date, sheet_count, rate, crown, post_class) + VALUES ('{}', '{}', '{}', '{}', '{}', '{}') + """.format(id, start_date, sheet_count, rate, crown, post_class)) + + +def downgrade(): + pass