ZeusWPI / zauth

Zeus AUTHentication Service
MIT License
6 stars 2 forks source link

Fix deleting clients #260

Closed rien closed 12 months ago

rien commented 1 year ago

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.

FKD13 commented 1 year ago

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