diff --git a/migrations/versions/0040_adjust_mmg_provider_rate.py b/migrations/versions/0040_adjust_mmg_provider_rate.py new file mode 100644 index 000000000..3666ca649 --- /dev/null +++ b/migrations/versions/0040_adjust_mmg_provider_rate.py @@ -0,0 +1,38 @@ +"""mmg rates now set to 1.65 pence per sms + +Revision ID: 0040_adjust_mmg_provider_rate +Revises: 0039_fix_notifications +Create Date: 2016-07-06 15:19:23.124212 + +""" + +# revision identifiers, used by Alembic. +revision = '0040_adjust_mmg_provider_rate' +down_revision = '0039_fix_notifications' + +import uuid +from datetime import datetime + +from alembic import op +import sqlalchemy as sa + +def upgrade(): + ### commands auto generated by Alembic - please adjust! ### + conn = op.get_bind() + conn.execute( + sa.sql.text(("INSERT INTO provider_rates (id, valid_from, rate, provider_id) " + "VALUES (:id, :valid_from, :rate, (SELECT id FROM provider_details WHERE identifier = 'mmg'))")), + id=uuid.uuid4(), + valid_from=datetime.utcnow(), + rate=1.65 + ) + ### end Alembic commands ### + + +def downgrade(): + ### commands auto generated by Alembic - please adjust! ### + conn = op.get_bind() + conn.execute(("DELETE FROM provider_rates " + "WHERE provider_id = (SELECT id FROM provider_details WHERE identifier = 'mmg') " + "AND rate = 1.65")) + ### end Alembic commands ###