Closes #19627: Object change migrators (#19628)

* Initial work on ObjectChange data migrations

* Fix migration bug

* Add migrators for MAC address assignments

* Update reverting kwarg; allow pop() to fail

* Cross-reference MAC address migrators

* Split migrator logic across migrations

* Add missing migrator
This commit is contained in:
Jeremy Stretch
2025-06-05 11:47:59 -04:00
committed by GitHub
parent bd8cf64ded
commit 179c06ec20
13 changed files with 261 additions and 1 deletions

View File

@@ -66,3 +66,17 @@ class Migration(migrations.Migration):
name='group',
),
]
def oc_contact_groups(objectchange, reverting):
for data in (objectchange.prechange_data, objectchange.postchange_data):
if data is None:
continue
# Set the M2M field `groups` to a list containing the group ID
data['groups'] = [data['group']] if data.get('group') else []
data.pop('group', None)
objectchange_migrators = {
'tenancy.contact': oc_contact_groups,
}