From 3c25c3a33526fad2286e502f535c5a64f175115d Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:29:28 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20the=20imports=20for?= =?UTF-8?q?=20models=20to=20use=20apps=20instead=20of=20direct=20import=20?= =?UTF-8?q?to=20fix=20install=20bug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/411.fixed | 1 + .../0007_replace_dashed_custom_fields.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 changes/411.fixed diff --git a/changes/411.fixed b/changes/411.fixed new file mode 100644 index 000000000..57faa9b2f --- /dev/null +++ b/changes/411.fixed @@ -0,0 +1 @@ +Fixed imports in CustomFields migration that was causing installation issues. \ No newline at end of file diff --git a/nautobot_ssot/migrations/0007_replace_dashed_custom_fields.py b/nautobot_ssot/migrations/0007_replace_dashed_custom_fields.py index 9bcd73088..5875846b9 100644 --- a/nautobot_ssot/migrations/0007_replace_dashed_custom_fields.py +++ b/nautobot_ssot/migrations/0007_replace_dashed_custom_fields.py @@ -1,7 +1,4 @@ from django.db import migrations -from nautobot.dcim.models import Device, DeviceType, Interface, Location, Manufacturer -from nautobot.extras.models import Role -from nautobot.ipam.models import VLAN, IPAddress CF_KEY_CHANGE_MAP = { "ssot_synced_to_servicenow": "ssot-synced-to-servicenow", @@ -12,6 +9,7 @@ def replace_dashed_custom_fields(apps, schema_editor): + """Replace dashes in CustomField keys with underscore.""" CustomField = apps.get_model("extras", "customfield") for new_key, old_key in CF_KEY_CHANGE_MAP.items(): @@ -23,7 +21,17 @@ def replace_dashed_custom_fields(apps, schema_editor): custom_field.key = new_key custom_field.save() - for model in [Device, DeviceType, Interface, Manufacturer, Location, VLAN, Role, IPAddress]: + for app, model in [ + ("dcim", "Device"), + ("dcim", "DeviceType"), + ("dcim", "Interface"), + ("dcim", "Manufacturer"), + ("dcim", "Location"), + ("ipam", "VLAN"), + ("extras", "Role"), + ("ipam", "IPAddress"), + ]: + model = apps.get_model(app, model) cf_list = [] for instance in model.objects.all(): for new_cf, old_cf in CF_KEY_CHANGE_MAP.items():