From ab14a8a71c78e76db29f2520eeec6ee079c280f3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 26 Jan 2024 10:20:42 -0800 Subject: [PATCH] 12510 add migration for job report to script --- .../migrations/0011_job_report_to_script.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 netbox/core/migrations/0011_job_report_to_script.py diff --git a/netbox/core/migrations/0011_job_report_to_script.py b/netbox/core/migrations/0011_job_report_to_script.py new file mode 100644 index 000000000..4273475ef --- /dev/null +++ b/netbox/core/migrations/0011_job_report_to_script.py @@ -0,0 +1,27 @@ +# Generated by Django 5.0.1 on 2024-01-26 18:11 + +from django.db import migrations + + +def migrate_report_jobs(apps, schema_editor): + ContentType = apps.get_model('contenttypes', 'ContentType') + Job = apps.get_model('core', 'Job') + + # Delete the new ContentType effected by the introduction of core.ConfigRevision + report_content_type = ContentType.objects.get(app_label='extras', model='reportmodule') + script_content_type = ContentType.objects.get(app_label='extras', model='scriptmodule') + jobs = Job.objects.filter(object_type_id=report_content_type.id).update(object_type_id=script_content_type.id) + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0010_gfk_indexes'), + ] + + operations = [ + migrations.RunPython( + code=migrate_report_jobs, + reverse_code=migrations.RunPython.noop + ), + ]