Skip to content

Commit

Permalink
clean-up-last-modifier-id: Don't delete guest users
Browse files Browse the repository at this point in the history
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
  • Loading branch information
reinhardt committed Jul 10, 2024
1 parent 03c6d18 commit 968802e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/euphorie/deployment/browser/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"

0 comments on commit 968802e

Please sign in to comment.