diff --git a/go/billing/migrations/0020_transaction_type_update.py b/go/billing/migrations/0020_transaction_type_update.py index 01e9314c8..58b24d7cf 100644 --- a/go/billing/migrations/0020_transaction_type_update.py +++ b/go/billing/migrations/0020_transaction_type_update.py @@ -8,14 +8,16 @@ class Migration(SchemaMigration): def forwards(self, orm): - messages = orm.Transaction.objects.exclude(message_direction='') - topups = orm.Transaction.objects.filter(message_direction='') + if not db.dry_run: + messages = orm.Transaction.objects.exclude(message_direction='') + topups = orm.Transaction.objects.filter(message_direction='') - messages.update(transaction_type='Message') - topups.update(transaction_type='Top Up') + messages.update(transaction_type='Message') + topups.update(transaction_type='Top Up') def backwards(self, orm): - orm.Transaction.objects.update(transaction_type=None) + if not db.dry_run: + orm.Transaction.objects.update(transaction_type=None) models = { u'auth.group': { diff --git a/go/billing/migrations/0023_auto__del_unique_messagecost_account_tag_pool_message_direction__add_u.py b/go/billing/migrations/0023_auto__del_unique_messagecost_account_tag_pool_message_direction__add_u.py index 324c88a9b..7539329b3 100644 --- a/go/billing/migrations/0023_auto__del_unique_messagecost_account_tag_pool_message_direction__add_u.py +++ b/go/billing/migrations/0023_auto__del_unique_messagecost_account_tag_pool_message_direction__add_u.py @@ -3,6 +3,7 @@ from south.db import db from south.v2 import SchemaMigration from django.db import models +from django.db.utils import DatabaseError class Migration(SchemaMigration): @@ -14,16 +15,24 @@ def forwards(self, orm): # Adding unique constraint on 'MessageCost', fields ['account', 'tag_pool', 'message_direction', 'provider'] db.create_unique(u'billing_messagecost', ['account_id', 'tag_pool_id', 'message_direction', 'provider']) - # Removing index on 'MessageCost', fields ['account', 'tag_pool', 'message_direction'] - db.delete_index(u'billing_messagecost', ['account_id', 'tag_pool_id', 'message_direction']) + try: + # Removing index on 'MessageCost', fields ['account', 'tag_pool', 'message_direction'] + db.delete_index(u'billing_messagecost', ['account_id', 'tag_pool_id', 'message_direction']) + except DatabaseError as e: + if not str(e).startswith("no such index: billing_messagecost_account_id_"): + raise # Adding index on 'MessageCost', fields ['account', 'tag_pool', 'message_direction', 'provider'] db.create_index(u'billing_messagecost', ['account_id', 'tag_pool_id', 'message_direction', 'provider']) def backwards(self, orm): - # Removing index on 'MessageCost', fields ['account', 'tag_pool', 'message_direction', 'provider'] - db.delete_index(u'billing_messagecost', ['account_id', 'tag_pool_id', 'message_direction', 'provider']) + try: + # Removing index on 'MessageCost', fields ['account', 'tag_pool', 'message_direction', 'provider'] + db.delete_index(u'billing_messagecost', ['account_id', 'tag_pool_id', 'message_direction', 'provider']) + except DatabaseError as e: + if not str(e).startswith("no such index: billing_messagecost_account_id_"): + raise # Adding index on 'MessageCost', fields ['account', 'tag_pool', 'message_direction'] db.create_index(u'billing_messagecost', ['account_id', 'tag_pool_id', 'message_direction']) @@ -173,4 +182,4 @@ def backwards(self, orm): } } - complete_apps = ['billing'] \ No newline at end of file + complete_apps = ['billing']