Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deleting clients #260

Merged
merged 2 commits into from
Nov 8, 2023
Merged

Fix deleting clients #260

merged 2 commits into from
Nov 8, 2023

Conversation

rien
Copy link
Collaborator

@rien rien commented Oct 26, 2023

Deleting clients with sessions would throw an error because of a constraint violation:

Internal error occurred: DatabaseError(DatabaseError(ForeignKeyViolation, "update or delete on table \"clients\" violates foreign key constraint \"sessions_client_id_fkey\" on table \"sessions\""))

This PR adds a test to reproduce this issue and fixes the issue by adding ON DELETE CASCADE to the foreign key constraint. This causes a delete on a client tot delete all associated sessions as well.

Are there any other relations where we want this to happen? I'm thinking of sessions referencing users (do we ever want to delete users?) etc.

Copy link
Member

@FKD13 FKD13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci! Ik zie hier niet direct vreemde dingen :D

@FKD13
Copy link
Member

FKD13 commented Oct 26, 2023

do we ever want to delete users?

Not urgently at the moment. But might be nice? The ability to disable users already gets us a long way

@xerbalind xerbalind merged commit 0e27313 into main Nov 8, 2023
3 checks passed
@xerbalind xerbalind deleted the fix/delete-client branch November 8, 2023 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants