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

Delete cascade from user to injects should never happen #272

Closed
SamuelHassine opened this issue Jun 2, 2023 · 4 comments · Fixed by #293
Closed

Delete cascade from user to injects should never happen #272

SamuelHassine opened this issue Jun 2, 2023 · 4 comments · Fixed by #293
Assignees
Labels
bug use for describing something not working as expected solved The issue has been solved
Milestone

Comments

@SamuelHassine
Copy link
Member

Description

When deleting a user in the platform, all injects created by the user are deleted. We need a "set null" behavior on the creator....

@SamuelHassine SamuelHassine added the bug use for describing something not working as expected label Jun 2, 2023
@guillaumejparis
Copy link
Member

guillaumejparis commented Sep 21, 2023

I reproduce it.
I found what causes this (w Romuald), in our db schema we have a delete cascade constraint on the inject from the user :

inject_user                 varchar(255) default NULL::character varying
        constraint fk_a60839b2e20fc097
            references users
            on delete cascade,

So to fix the problem we need to make a migration but before rush headfirst I prefer to ask you @richard-julien, do you remember if there is a good reason to have done that ?

@richard-julien
Copy link
Member

No memories on that. I think it was implemented with cascade like this for everything related to the user. I think you should take a look on the other user cascade to see if you need to prevent this behavior on other objects

@guillaumejparis
Copy link
Member

Ok I checked all the others delete cascade for the user, they seem legit the only one that I have a doubt is the logs one :

create table if not exists logs
(
    log_id       varchar(255)                not null
        constraint logs_pkey
            primary key,
    log_exercise varchar(255) default NULL::character varying
        constraint fk_f08fc65cc0891ec3
            references exercises
            on delete cascade,
    log_user     varchar(255) default NULL::character varying
        constraint fk_f08fc65c9cfd383c
            references users
            on delete cascade,
    log_title    varchar(255)                not null,
    log_content  text                        not null,
    log_date     timestamp(0) with time zone not null
); 

Not sure if we want to keep this kind of logs even when user is deleted

@RomuDeuxfois
Copy link
Member

Agree, I am not sure this is useful to keep it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug use for describing something not working as expected solved The issue has been solved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants