mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
Extend migration to update content types
This commit is contained in:
parent
0195c06863
commit
6a7d909757
@ -1,6 +1,19 @@
|
|||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def update_content_types(apps, schema_editor):
|
||||||
|
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||||
|
|
||||||
|
# Delete the new ContentTypes effected by the new models in the vpn app
|
||||||
|
ContentType.objects.filter(app_label='vpn', model='l2vpn').delete()
|
||||||
|
ContentType.objects.filter(app_label='vpn', model='l2vpntermination').delete()
|
||||||
|
|
||||||
|
# Update the app labels of the original ContentTypes for ipam.L2VPN and ipam.L2VPNTermination to ensure
|
||||||
|
# that any foreign key references are preserved
|
||||||
|
ContentType.objects.filter(app_label='ipam', model='l2vpn').update(app_label='vpn')
|
||||||
|
ContentType.objects.filter(app_label='ipam', model='l2vpntermination').update(app_label='vpn')
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
@ -44,4 +57,8 @@ class Migration(migrations.Migration):
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
code=update_content_types,
|
||||||
|
reverse_code=migrations.RunPython.noop
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user