GitHub user xavier-GitHub76 added a comment to the discussion: cannot delete 
user "Associated data exists, please delete them first"

Hello,
I systematically reproduce the problem "impossible to delete a user : 
Associated data exists, please delete them first".

Creation of a user (alpha) + Login of the user + Creation of a chart by the 
user + Deletion of the chart by the user + Deletion of the user => Associated 
data exists, please delete them first

I have identified the cause: This only concerns users who have created elements 
in Superset. Despite the deletion of elements created by a user from the 
graphical user interface, the deletion of the user is impossible because the 
"key_value" table is not cleaned at the time of deletion, this creates an 
integrity constraint preventing the deletion of the user.

The other tables (logs, slices, slice_user) are correctly updated.

The “key_value” table has a relationship only with the “ab_user” table.
![image](https://github.com/apache/superset/assets/82046143/4530d270-0101-4039-b436-73ea142ee970)

It is possible to work around the problem by executing a delete query on the 
key_value table :
delete from public.key_value where created_by_fk = <id_user_to_delete>

Testing the workaround : 
"Deleted Row" 👍 

The following tables are well updated:
    • ab_user.sql
        ◦ Deletion of the line relating to the user
    • ab_user_role.sql
        ◦ Deletion of the line relating to the user
    • logs.sql
        ◦ Lines mentioning <user id>  now mention user = None (like a user 
deleted without objects created)

Best regards

GitHub link: 
https://github.com/apache/superset/discussions/40137#discussioncomment-16924822

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to