From 2a4ba5bd362f4a1d638c1216e2f10c416ad80ca7 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 15:26:39 -0700 Subject: [PATCH] 19680 add object_change migrator --- .../extras/migrations/0129_fix_script_paths.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/netbox/extras/migrations/0129_fix_script_paths.py b/netbox/extras/migrations/0129_fix_script_paths.py index 88f57634c..047a13f57 100644 --- a/netbox/extras/migrations/0129_fix_script_paths.py +++ b/netbox/extras/migrations/0129_fix_script_paths.py @@ -38,3 +38,20 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython(code=fix_script_paths, reverse_code=migrations.RunPython.noop), ] + + +def oc_fix_script_paths(objectchange, reverting): + script_root_path = normalize(settings.SCRIPTS_ROOT) + + for data in (objectchange.prechange_data, objectchange.postchange_data): + if data is None: + continue + + if file_path := data.get('file_path'): + if file_path.startswith(script_root_path): + data['file_path'] = file_path[len(script_root_path):] + + +objectchange_migrators = { + 'extras.scriptmodule': oc_fix_script_paths, +}