GitHub user jl141 added a comment to the discussion: cannot delete user "Associated data exists, please delete them first"
@michael-s-molina Thanks for the reply! We've looked into the items you brought up and have modified our approach: - When an admin deletes a user, we will require them to choose a user to reassign assets (dashboards, charts, saved queries) to, given that there exists associated data. - Regarding other data, we will either set the delete rule on `ab_user.id` to be `CASCADE` or `SET NULL`, depending on whether they are saved in the tables as `user_id` or `changed/created/last_saved_by_fk`. e.g. `CASCADE` on tables `ab_user_role`, `favstar`, `query`, `sql_metrics`, etc. and `SET NULL` on tables `ab_user`, `annotation`, `annotation_layer`, `dbs`, etc. - Regarding log data integrity in the context of deleting a user: The logs table contains references to user IDs that seemingly cannot be broken. Thus in the case of the hard deleting a user, we are unsure how to achieve this selective deletion. - One option is to `CASCADE` delete the logs along with the user, but this is not ideal if the logs are needed for later reference or legal purposes. - Another option is to soft delete the user instead by keeping the deleted user in the `ab_user` table, and changing its username from “X” to “[DELETED]_X”, which would keep the logs intact while allowing the username “X” to be reused. However, this would also mean that the other data (as in the bullet above) would neither be deleted nor set null, and we may run into the aforementioned problem of substantial logic changes. - An additional option (utilizing `SET NULL` delete rule on `ab_user.id`) is to add a column `user_info` to the logs table that provides information about the user (e.g. username + email) and logic to access this information when it turns out that `user_id` is null. GitHub link: https://github.com/apache/superset/discussions/40137#discussioncomment-16924837 ---- 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]
