Просмотр исходного кода

Fixes #3967: Fix missing migration for interface templates of type "other"

Jeremy Stretch 6 лет назад
Родитель
Сommit
8cfb5ac5c6

+ 1 - 0
docs/release-notes/version-2.7.md

@@ -8,6 +8,7 @@
 ## Bug Fixes
 
 * [#2519](https://github.com/netbox-community/netbox/issues/2519) - Avoid race condition when provisioning "next available" IPs/prefixes via the API
+* [#3967](https://github.com/netbox-community/netbox/issues/3967) - Fix missing migration for interface templates of type "other"
 * [#4168](https://github.com/netbox-community/netbox/issues/4168) - Role is not required when creating a virtual machine
 * [#4175](https://github.com/netbox-community/netbox/issues/4175) - Fix potential exception when bulk editing objects from a filtered list
 * [#4179](https://github.com/netbox-community/netbox/issues/4179) - Site is required when creating a rack group or power panel

+ 20 - 0
netbox/dcim/migrations/0097_interfacetemplate_type_other.py

@@ -0,0 +1,20 @@
+from django.db import migrations
+
+
+def interfacetemplate_type_to_slug(apps, schema_editor):
+    InterfaceTemplate = apps.get_model('dcim', 'InterfaceTemplate')
+    InterfaceTemplate.objects.filter(type=32767).update(type='other')
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('dcim', '0096_interface_ordering'),
+    ]
+
+    operations = [
+        # Missed type "other" in the initial migration (see #3967)
+        migrations.RunPython(
+            code=interfacetemplate_type_to_slug
+        ),
+    ]