mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 04:58:16 -06:00
10587 fix migrations
This commit is contained in:
parent
c027c4fa24
commit
bbdf5c76cb
@ -25,7 +25,4 @@ class Migration(migrations.Migration):
|
|||||||
migrations.DeleteModel(
|
migrations.DeleteModel(
|
||||||
name='Report',
|
name='Report',
|
||||||
),
|
),
|
||||||
migrations.DeleteModel(
|
|
||||||
name='ReportModule',
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
@ -82,10 +82,12 @@ def update_scripts(apps, schema_editor):
|
|||||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||||
Script = apps.get_model('extras', 'Script')
|
Script = apps.get_model('extras', 'Script')
|
||||||
ScriptModule = apps.get_model('extras', 'ScriptModule')
|
ScriptModule = apps.get_model('extras', 'ScriptModule')
|
||||||
|
ReportModule = apps.get_model('extras', 'ReportModule')
|
||||||
Job = apps.get_model('core', 'Job')
|
Job = apps.get_model('core', 'Job')
|
||||||
|
|
||||||
script_ct = ContentType.objects.get_for_model(Script)
|
script_ct = ContentType.objects.get_for_model(Script, for_concrete_model=False)
|
||||||
scriptmodule_ct = ContentType.objects.get_for_model(ScriptModule)
|
scriptmodule_ct = ContentType.objects.get_for_model(ScriptModule, for_concrete_model=False)
|
||||||
|
reportmodule_ct = ContentType.objects.get_for_model(ReportModule, for_concrete_model=False)
|
||||||
|
|
||||||
for module in ScriptModule.objects.all():
|
for module in ScriptModule.objects.all():
|
||||||
for script_name in get_module_scripts(module):
|
for script_name in get_module_scripts(module):
|
||||||
@ -100,6 +102,12 @@ def update_scripts(apps, schema_editor):
|
|||||||
object_id=module.pk,
|
object_id=module.pk,
|
||||||
name=script_name
|
name=script_name
|
||||||
).update(object_type_id=script_ct.id, object_id=script.pk)
|
).update(object_type_id=script_ct.id, object_id=script.pk)
|
||||||
|
# Update all Jobs associated with this ScriptModule & script name to point to the new Script object
|
||||||
|
Job.objects.filter(
|
||||||
|
object_type_id=reportmodule_ct.id,
|
||||||
|
object_id=module.pk,
|
||||||
|
name=script_name
|
||||||
|
).update(object_type_id=script_ct.id, object_id=script.pk)
|
||||||
|
|
||||||
|
|
||||||
def update_event_rules(apps, schema_editor):
|
def update_event_rules(apps, schema_editor):
|
||||||
|
@ -12,4 +12,7 @@ class Migration(migrations.Migration):
|
|||||||
model_name='eventrule',
|
model_name='eventrule',
|
||||||
name='action_parameters',
|
name='action_parameters',
|
||||||
),
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='ReportModule',
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user