Commit d0891d38 by Őry Máté

vm: fix migrations

parent f19b455c
...@@ -9,7 +9,10 @@ class Migration(SchemaMigration): ...@@ -9,7 +9,10 @@ class Migration(SchemaMigration):
def forwards(self, orm): def forwards(self, orm):
# Removing unique constraint on 'InstanceTemplate', fields ['name'] # Removing unique constraint on 'InstanceTemplate', fields ['name']
try:
db.delete_unique(u'vm_instancetemplate', ['name']) db.delete_unique(u'vm_instancetemplate', ['name'])
except Exception as e:
print unicode(e)
# Changing field 'InstanceTemplate.parent' # Changing field 'InstanceTemplate.parent'
......
...@@ -7,34 +7,45 @@ class Migration(SchemaMigration): ...@@ -7,34 +7,45 @@ class Migration(SchemaMigration):
def forwards(self, orm): def forwards(self, orm):
db.start_transaction()
# Adding field 'InstanceActivity.result_data' # Adding field 'InstanceActivity.result_data'
db.add_column(u'vm_instanceactivity', 'result_data', db.add_column(u'vm_instanceactivity', 'result_data',
self.gf('jsonfield.fields.JSONField')(null=True, blank=True), self.gf('jsonfield.fields.JSONField')(null=True, blank=True),
keep_default=False) keep_default=False)
# Adding field 'NodeActivity.result_data'
db.add_column(u'vm_nodeactivity', 'result_data',
self.gf('jsonfield.fields.JSONField')(null=True, blank=True),
keep_default=False)
db.commit_transaction()
db.start_transaction()
for i in orm.InstanceActivity.objects.all(): for i in orm.InstanceActivity.objects.all():
result = i.result.replace("%", "%%") if i.result else "" result = i.result.replace("%", "%%") if i.result else ""
i.result_data = {"user_text_template": "", i.result_data = {"user_text_template": "",
"admin_text_template": result, "params": {}} "admin_text_template": result, "params": {}}
i.save() i.save()
# Deleting field 'InstanceActivity.result'
db.delete_column(u'vm_instanceactivity', 'result')
# Adding field 'NodeActivity.result_data'
db.add_column(u'vm_nodeactivity', 'result_data',
self.gf('jsonfield.fields.JSONField')(null=True, blank=True),
keep_default=False)
for i in orm.NodeActivity.objects.all(): for i in orm.NodeActivity.objects.all():
result = i.result.replace("%", "%%") if i.result else "" result = i.result.replace("%", "%%") if i.result else ""
i.result_data = {"user_text_template": "", i.result_data = {"user_text_template": "",
"admin_text_template": result, "params": {}} "admin_text_template": result, "params": {}}
i.save() i.save()
db.commit_transaction()
db.start_transaction()
# Deleting field 'InstanceActivity.result'
db.delete_column(u'vm_instanceactivity', 'result')
# Deleting field 'NodeActivity.result' # Deleting field 'NodeActivity.result'
db.delete_column(u'vm_nodeactivity', 'result') db.delete_column(u'vm_nodeactivity', 'result')
db.commit_transaction()
def backwards(self, orm): def backwards(self, orm):
# Adding field 'InstanceActivity.result' # Adding field 'InstanceActivity.result'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment