From 968802e24d13933c1c4165f45d34faf13455c67b Mon Sep 17 00:00:00 2001 From: Manuel Reinhardt Date: Wed, 10 Jul 2024 12:17:49 +0200 Subject: [PATCH] clean-up-last-modifier-id: Don't delete guest users Fixes sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (psycopg2.errors.ForeignKeyViolation) update or delete on table "account" violates foreign key constraint "session_last_modifier_id_fkey" on table "session" DETAIL: Key (id)=(...) is still referenced from table "session". Ref syslabcom/scrum#2372 --- src/euphorie/deployment/browser/maintenance.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/euphorie/deployment/browser/maintenance.py b/src/euphorie/deployment/browser/maintenance.py index dc12ebbb7..d2d33a6ff 100644 --- a/src/euphorie/deployment/browser/maintenance.py +++ b/src/euphorie/deployment/browser/maintenance.py @@ -2,6 +2,7 @@ from euphorie.client.model import Session from euphorie.client.model import SurveySession from Products.Five import BrowserView +from sqlalchemy.exc import SQLAlchemyError import logging @@ -29,7 +30,4 @@ def __call__(self): .filter(SurveySession.account_id == guest_user.id) .count() ) - if num_assessments == 0: - session.delete(guest_user) - logger.info("Deleted user %s", guest_user.id) return "Done"