Skip to content

Commit c3f1fcd

Browse files
committed
Handle global assignments in migration
1 parent e932698 commit c3f1fcd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ansible_base/rbac/migrations/0005_remote_permissions_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ def migrate_content_type(apps, schema_editor):
2020
cls = apps.get_model('dab_rbac', model_name)
2121
for obj in cls.objects.all():
2222
old_ct = obj.content_type
23-
# NOTE: could give duplicate normally, but that is impossible in migration path
24-
obj.new_content_type = ct_cls.objects.get_by_natural_key(old_ct.app_label, old_ct.model)
25-
obj.save()
23+
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)
26+
obj.save()
2627
for model_name in ('roleevaluation', 'roleevaluationuuid'):
2728
cls = apps.get_model('dab_rbac', model_name)
2829
cls.objects.all().delete()

0 commit comments

Comments
 (0)