diff options
author | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-05-23 17:20:01 +0200 |
---|---|---|
committer | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-06-10 22:36:22 +0200 |
commit | d16b69a102dc0babb2e7047635100343cf8f63f5 (patch) | |
tree | ac89b041c0f30214039850bc8065a692a0e3a319 /tools/scripts/ig-hotfix | |
parent | Do not throw away the container of cross-linked parents (diff) | |
download | awx-d16b69a102dc0babb2e7047635100343cf8f63f5.tar.xz awx-d16b69a102dc0babb2e7047635100343cf8f63f5.zip |
Add output of the update and deletion counts to fix.py
Diffstat (limited to 'tools/scripts/ig-hotfix')
-rw-r--r-- | tools/scripts/ig-hotfix/role_check.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/scripts/ig-hotfix/role_check.py b/tools/scripts/ig-hotfix/role_check.py index 3f11c5d5a8..4b84926a92 100644 --- a/tools/scripts/ig-hotfix/role_check.py +++ b/tools/scripts/ig-hotfix/role_check.py @@ -125,16 +125,24 @@ sys.stderr.write('===================================\n') print(f"""\ +from collections import Counter + from django.contrib.contenttypes.models import ContentType from awx.main.models.rbac import Role + +delete_counts = Counter() +update_counts = Counter() + """) print("# Role objects that are assigned to objects that do not exist") for r in orphaned_roles: - print(f"Role.objects.filter(id={r}).update(object_id=None)") - print(f"Role.objects.filter(id={r}).delete()") + print(f"c = Role.objects.filter(id={r}).update(object_id=None)") + print("update_counts.update({'main.Role': c})") + print(f"_, c = Role.objects.filter(id={r}).delete()") + print("delete_counts.update(c)") print("\n") @@ -145,13 +153,17 @@ print("queue = []\n") for ct, objs in crosslinked.items(): print(f"cls = ContentType.objects.get(id={ct}).model_class()\n") for obj, kv in objs.items(): - print(f"cls.objects.filter(id={obj}).update(**{kv!r})") + print(f"c = cls.objects.filter(id={obj}).update(**{kv!r})") + print("update_counts.update({repr(cls): c})") print(f"queue.append((cls, {obj}))") for child, parents in crosslinked_parents.items(): print(f"\n\nr = Role.objects.get(id={child})") print(f"r.parents.remove(*Role.objects.filter(id__in={parents!r}))") +print('print("Objects deleted:", delete_counts)') +print('print("Objects updated:", update_counts)') + print(f"\n\nfor cls, obj_id in queue:") print(f" obj = cls.objects.get(id=obj_id)") print(f" obj.save()") |