mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-23 17:28:49 +02:00
* 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:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user