14438 fix migration

This commit is contained in:
Arthur 2024-02-06 10:43:13 -08:00
parent 9543169025
commit d162d440b0

View File

@ -9,7 +9,7 @@ def update_scripts(apps, schema_editor):
ScriptModuleNew = apps.get_model('extras', 'ScriptModule') ScriptModuleNew = apps.get_model('extras', 'ScriptModule')
Script = apps.get_model('extras', 'Script') Script = apps.get_model('extras', 'Script')
ContentType = apps.get_model('contenttypes', 'ContentType') ContentType = apps.get_model('contenttypes', 'ContentType')
ct = ContentType.objects.get(app_label='extras', model='script') ct = ContentType.objects.filter(app_label='extras', model='script').first()
for module in ScriptModule.objects.all(): for module in ScriptModule.objects.all():
for script in module.get_module_scripts.keys(): for script in module.get_module_scripts.keys():
@ -19,6 +19,7 @@ def update_scripts(apps, schema_editor):
) )
# update all jobs associated with this module/name to point to the new script obj # update all jobs associated with this module/name to point to the new script obj
if ct:
module.jobs.filter(name=script).update(object_type=ct, object_id=obj.id) module.jobs.filter(name=script).update(object_type=ct, object_id=obj.id)