Split migrator logic across migrations

This commit is contained in:
Jeremy Stretch 2025-06-03 15:32:17 -04:00
parent 71ee2a996e
commit d223c01dcd
8 changed files with 46 additions and 6 deletions

View File

@ -68,8 +68,6 @@ def oc_circuittermination_termination(objectchange, reverting):
'termination_type': provider_network_ct,
'termination_id': provider_network_id,
})
data.pop('site', None)
data.pop('provider_network', None)
objectchange_migrators = {

View File

@ -86,3 +86,15 @@ class Migration(migrations.Migration):
new_name='_provider_network',
),
]
def oc_circuittermination_remove_fields(objectchange, reverting):
for data in (objectchange.prechange_data, objectchange.postchange_data):
if data is not None:
data.pop('site', None)
data.pop('provider_network', None)
objectchange_migrators = {
'circuits.circuittermination': oc_circuittermination_remove_fields,
}

View File

@ -57,7 +57,6 @@ def oc_prefix_scope(objectchange, reverting):
'scope_type': site_ct,
'scope_id': site_id,
})
data.pop('site', None)
objectchange_migrators = {

View File

@ -60,3 +60,14 @@ class Migration(migrations.Migration):
name='site',
),
]
def oc_prefix_remove_fields(objectchange, reverting):
for data in (objectchange.prechange_data, objectchange.postchange_data):
if data is not None:
data.pop('site', None)
objectchange_migrators = {
'ipam.prefix': oc_prefix_remove_fields,
}

View File

@ -73,8 +73,6 @@ def oc_service_parent(objectchange, reverting):
'parent_object_type': virtual_machine_ct,
'parent_object_id': virtual_machine_id,
})
data.pop('device', None)
data.pop('virtual_machine', None)
objectchange_migrators = {

View File

@ -37,3 +37,15 @@ class Migration(migrations.Migration):
),
),
]
def oc_service_remove_fields(objectchange, reverting):
for data in (objectchange.prechange_data, objectchange.postchange_data):
if data is not None:
data.pop('device', None)
data.pop('virtual_machine', None)
objectchange_migrators = {
'ipam.service': oc_service_remove_fields,
}

View File

@ -56,7 +56,6 @@ def oc_cluster_scope(objectchange, reverting):
'scope_type': site_ct,
'scope_id': site_id,
})
data.pop('site', None)
objectchange_migrators = {

View File

@ -87,3 +87,14 @@ class Migration(migrations.Migration):
),
),
]
def oc_cluster_remove_site(objectchange, reverting):
for data in (objectchange.prechange_data, objectchange.postchange_data):
if data is not None:
data.pop('site', None)
objectchange_migrators = {
'virtualization.cluster': oc_cluster_remove_site,
}