<commit_before># -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Deleting field 'Account.alert_credit_balance'
        db.delete_column(u'billing_account', 'alert_credit_balance')

        # Deleting field 'Account.alert_threshold'
        db.delete_column(u'billing_account', 'alert_threshold')

        # Adding field 'Account.last_topup_balance'
        db.add_column(u'billing_account', 'last_topup_balance',
                      self.gf('django.db.models.fields.DecimalField')(default='0.0', max_digits=20, decimal_places=6),
                      keep_default=False)


    def backwards(self, orm):
        # Adding field 'Account.alert_credit_balance'
        db.add_column(u'billing_account', 'alert_credit_balance',
                      self.gf('django.db.models.fields.DecimalField')(default='0.0', max_digits=20, decimal_places=6),
                      keep_default=False)

        # Adding field 'Account.alert_threshold'
        db.add_column(u'billing_account', 'alert_threshold',
                      self.gf('django.db.models.fields.DecimalField')(default='0.0', max_digits=10, decimal_places=2),
                      keep_default=False)

        # Deleting field 'Account.last_topup_balance'
        db.delete_column(u'billing_account', 'last_topup_balance')


    models = {
        u'auth.group': {
            'Meta': {'object_name': 'Group'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})<commit_msg>Change migration to set last_topup_balance according to alert_credit_balance and alert_threshold before deleting alter_*<commit_after># -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Adding field 'Account.last_topup_balance'
        db.add_column(u'billing_account', 'last_topup_balance',
                      self.gf('django.db.models.fields.DecimalField')(default='0.0', max_digits=20, decimal_places=6),
                      keep_default=False)

        # Populate the last_topup_balance fields with values
        db.execute(
            """
            UPDATE billing_account SET last_topup_balance =
            alert_credit_balance / alert_threshold
            """)

        # Deleting field 'Account.alert_credit_balance'
        db.delete_column(u'billing_account', 'alert_credit_balance')

        # Deleting field 'Account.alert_threshold'
        db.delete_column(u'billing_account', 'alert_threshold')

    def backwards(self, orm):
        # Adding field 'Account.alert_credit_balance'
        db.add_column(u'billing_account', 'alert_credit_balance',
                      self.gf('django.db.models.fields.DecimalField')(default='0.0', max_digits=20, decimal_places=6),
                      keep_default=False)

        # Adding field 'Account.alert_threshold'
        db.add_column(u'billing_account', 'alert_threshold',
                      self.gf('django.db.models.fields.DecimalField')(default='0.0', max_digits=10, decimal_places=2),
                      keep_default=False)

        # Deleting field 'Account.last_topup_balance'
        db.delete_column(u'billing_account', 'last_topup_balance')


    models = {
        u'auth.group': {
            'Meta': {'object_name': 'Group'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
{'fraction_non_alphanumeric': 0.13676255485129205, 'fraction_numerical': 0.009263773768893223, 'mean_word_length': 3.010752688172043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '836068', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1203, 'n_words': 204}