statbot icon indicating copy to clipboard operation
statbot copied to clipboard

Relax foreign key constraints on Audit logs and reactions

Open theKAKAN opened this issue 2 years ago • 0 comments

The problem happens when a user has added some reaction, or has their ID in the audit log, but have left the server. In that case, we get a bunch of errors of foreign key violations because the user doesn't exist in the users table. I'm not sure if the better way is to remove foreign key, or just create a dummy "Unknown user" in the users table...

psycopg2.errors.ForeignKeyViolation: insert or update on table "audit_log" violates foreign key constraint "audit_log_int_user_id_fkey"
DETAIL:  Key (int_user_id)=([REDACTED]) is not present in table "users".

sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) insert or update on table "reactions" violates foreign key constraint "reactions_int_user_id_fkey"
DETAIL:  Key (int_user_id)=([REDACTED]) is not present in table "users".

theKAKAN avatar May 16 '23 07:05 theKAKAN