From ab5fd972b0fcd6d1e418ab00058b6fd31014d38f Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Tue, 5 Feb 2019 15:00:53 +0000 Subject: [PATCH] Migrate postage into templates_history table --- .../versions/0256_set_postage_tmplt_hstr.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 migrations/versions/0256_set_postage_tmplt_hstr.py diff --git a/migrations/versions/0256_set_postage_tmplt_hstr.py b/migrations/versions/0256_set_postage_tmplt_hstr.py new file mode 100644 index 000000000..f70e3bfbc --- /dev/null +++ b/migrations/versions/0256_set_postage_tmplt_hstr.py @@ -0,0 +1,28 @@ +""" + +Revision ID: 0256_set_postage_tmplt_hstr +Revises: 0255_another_letter_org +Create Date: 2019-02-05 14:51:30.808067 + +""" +from alembic import op +import sqlalchemy as sa + + +revision = '0256_set_postage_tmplt_hstr' +down_revision = '0255_another_letter_org' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.execute( + """UPDATE templates_history SET postage = services.postage + FROM services WHERE template_type = 'letter' AND service_id = services.id""" + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.execute("UPDATE templates_history SET postage = null WHERE template_type = 'letter'") + # ### end Alembic commands ###