From f56a8c16b086561d220a3dc9b7d90cdbec75bbeb Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 14 Jul 2014 16:07:18 -0400 Subject: [PATCH] Give a distinct hostname to satisfy the new unique constraint for job host summary, show that it is derived from a removed host --- awx/main/migrations/0047_v200_changes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/migrations/0047_v200_changes.py b/awx/main/migrations/0047_v200_changes.py index 3bbb60e734..0b46828911 100644 --- a/awx/main/migrations/0047_v200_changes.py +++ b/awx/main/migrations/0047_v200_changes.py @@ -8,11 +8,15 @@ from django.db import models class Migration(DataMigration): def forwards(self, orm): + idx = 0 for jhs in orm.JobHostSummary.objects.all(): print "JHS: Host: " + str(jhs.host) if jhs.host is not None and jhs.host.active: jhs.host_name = jhs.host.name - jhs.save() + else: + jhs.host_name = "tower_deleted_host-%s" % str(idx) + jhs.save() + idx += 1 def backwards(self, orm): print("Not reversing jobhoststatus host_name field")