From 199c43c5077b7ab91147ec473168d6ccf811e381 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Fri, 2 Jun 2017 16:49:11 +0100 Subject: [PATCH] Migration script to populate the provider. - initial build of this ONLY support MMG so we can assume that all existing entries are all MMG, so any nulls == MMG. - This PR will put in fire text so not so safe to keep doing this back and forward. --- ...ovider.py => 0091_add_inbound_provider.py} | 4 ++-- .../0092_populate_inbound_provider.py | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) rename migrations/versions/{0090_add_inbound_provider.py => 0091_add_inbound_provider.py} (84%) create mode 100644 migrations/versions/0092_populate_inbound_provider.py diff --git a/migrations/versions/0090_add_inbound_provider.py b/migrations/versions/0091_add_inbound_provider.py similarity index 84% rename from migrations/versions/0090_add_inbound_provider.py rename to migrations/versions/0091_add_inbound_provider.py index c110ac193..a0864ddbe 100644 --- a/migrations/versions/0090_add_inbound_provider.py +++ b/migrations/versions/0091_add_inbound_provider.py @@ -1,13 +1,13 @@ """empty message -Revision ID: 0090_add_inbound_provider +Revision ID: 0091_add_inbound_provider Revises: 0090_inbound_sms Create Date: 2017-06-02 16:07:35.445423 """ # revision identifiers, used by Alembic. -revision = '0090_add_inbound_provider' +revision = '0091_add_inbound_provider' down_revision = '0090_inbound_sms' from alembic import op diff --git a/migrations/versions/0092_populate_inbound_provider.py b/migrations/versions/0092_populate_inbound_provider.py new file mode 100644 index 000000000..ba6da1f5d --- /dev/null +++ b/migrations/versions/0092_populate_inbound_provider.py @@ -0,0 +1,22 @@ +"""empty message + +Revision ID: 0092_populate_inbound_provider +Revises: 0091_add_inbound_provider +Create Date: 2017-05-22 10:23:43.939050 + +""" + +# revision identifiers, used by Alembic. +revision = '0092_populate_inbound_provider' +down_revision = '0091_add_inbound_provider' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +def upgrade(): + op.execute("UPDATE inbound_sms SET provider='mmg' WHERE provider is null") + + +def downgrade(): + op.execute("UPDATE inbound_sms SET provider=null WHERE provider = 'mmg'")