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.
Deleting clients with sessions would throw an error because of a constraint violation:
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.