Loading trapper/trapper-project/trapper/apps/storage/migrations/0035_alter_resource_deployment.py +7 −3 Original line number Diff line number Diff line Loading @@ -34,16 +34,20 @@ def disable_triggers_safely(apps, schema_editor): def enable_triggers_safely(apps, schema_editor): """ Re-enable triggers on storage_resource. Try ALL first, then USER. If both attempts fail, raise an error to stop the migration and alert operators. """ if getattr(schema_editor.connection, "vendor", None) != "postgresql": return try: schema_editor.execute("ALTER TABLE storage_resource ENABLE TRIGGER ALL;") except Exception: except Exception as all_exc: try: schema_editor.execute("ALTER TABLE storage_resource ENABLE TRIGGER USER;") except Exception: pass except Exception as user_exc: raise RuntimeError( "Failed to re-enable triggers on storage_resource using both ALL and USER. " "Manual intervention is required to re-enable triggers." ) from user_exc class Migration(migrations.Migration): Loading Loading
trapper/trapper-project/trapper/apps/storage/migrations/0035_alter_resource_deployment.py +7 −3 Original line number Diff line number Diff line Loading @@ -34,16 +34,20 @@ def disable_triggers_safely(apps, schema_editor): def enable_triggers_safely(apps, schema_editor): """ Re-enable triggers on storage_resource. Try ALL first, then USER. If both attempts fail, raise an error to stop the migration and alert operators. """ if getattr(schema_editor.connection, "vendor", None) != "postgresql": return try: schema_editor.execute("ALTER TABLE storage_resource ENABLE TRIGGER ALL;") except Exception: except Exception as all_exc: try: schema_editor.execute("ALTER TABLE storage_resource ENABLE TRIGGER USER;") except Exception: pass except Exception as user_exc: raise RuntimeError( "Failed to re-enable triggers on storage_resource using both ALL and USER. " "Manual intervention is required to re-enable triggers." ) from user_exc class Migration(migrations.Migration): Loading