1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Migrate VLANGroup site assignments

This commit is contained in:
jeremystretch
2021-04-05 11:40:46 -04:00
parent 0a1531ce8a
commit 7949a5e1fd

View File

@ -0,0 +1,27 @@
from django.db import migrations
def set_scope_types(apps, schema_editor):
"""
Set 'site' as the scope type for all VLANGroups with a scope ID defined.
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
VLANGroup = apps.get_model('ipam', 'VLANGroup')
site_ct = ContentType.objects.get(app_label='dcim', model='site').pk
VLANGroup.objects.filter(scope_id__isnull=False).update(
scope_type=site_ct
)
class Migration(migrations.Migration):
dependencies = [
('ipam', '0045_vlangroup_scope'),
]
operations = [
migrations.RunPython(
code=set_scope_types
),
]