10587 fix migrations

This commit is contained in:
Arthur 2024-02-29 14:06:44 -08:00
parent c027c4fa24
commit bbdf5c76cb
3 changed files with 13 additions and 5 deletions

View File

@ -25,7 +25,4 @@ class Migration(migrations.Migration):
migrations.DeleteModel(
name='Report',
),
migrations.DeleteModel(
name='ReportModule',
),
]

View File

@ -82,10 +82,12 @@ def update_scripts(apps, schema_editor):
ContentType = apps.get_model('contenttypes', 'ContentType')
Script = apps.get_model('extras', 'Script')
ScriptModule = apps.get_model('extras', 'ScriptModule')
ReportModule = apps.get_model('extras', 'ReportModule')
Job = apps.get_model('core', 'Job')
script_ct = ContentType.objects.get_for_model(Script)
scriptmodule_ct = ContentType.objects.get_for_model(ScriptModule)
script_ct = ContentType.objects.get_for_model(Script, for_concrete_model=False)
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 script_name in get_module_scripts(module):
@ -100,6 +102,12 @@ def update_scripts(apps, schema_editor):
object_id=module.pk,
name=script_name
).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):

View File

@ -12,4 +12,7 @@ class Migration(migrations.Migration):
model_name='eventrule',
name='action_parameters',
),
migrations.DeleteModel(
name='ReportModule',
),
]