Skip to content

Commit 8640c70

Browse files
committed
more error info
1 parent c3f1fcd commit 8640c70

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ansible_base/rbac/migrations/0005_remote_permissions_data.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ def migrate_content_type(apps, schema_editor):
2121
for obj in cls.objects.all():
2222
old_ct = obj.content_type
2323
if old_ct:
24-
# NOTE: could give duplicate normally, but that is impossible in migration path
25-
obj.new_content_type = ct_cls.objects.get_by_natural_key(old_ct.app_label, old_ct.model)
24+
try:
25+
# NOTE: could give duplicate normally, but that is impossible in migration path
26+
obj.new_content_type = ct_cls.objects.get_by_natural_key(old_ct.app_label, old_ct.model)
27+
except Exception as e:
28+
raise RuntimeError(
29+
f"Failed to get new content type for a {model_name} pk={obj.pk}, obj={obj.__dict__}"
30+
) from e
2631
obj.save()
2732
for model_name in ('roleevaluation', 'roleevaluationuuid'):
2833
cls = apps.get_model('dab_rbac', model_name)

0 commit comments

Comments
 (0)