Description
If a user had created Review items on any controls in a component, then that user account gets deleted, the Reviews still exist with a null user id, and this prevents the Component from loading.
Recommended fix would be one of the following:
- When user is deleted, either assign the project admin user id to the review records, or prompt for a user to assign them to (especially if the project admin is the user being deleted - not sure what other issues that would produce)
- Leave the user id null, but in the Component load, check for the null user id on the Review, and add a label, like "Unknown User" or something similar, allowing the Component to load.
In the short term, to fix this manually in our local database, we did the following:
- Get a list of problem records (project, component, component release/version):
select distinct p.name, c.name, c.id as component_id, 'v' || c.version || 'r' || c.release as release from projects p, components c, base_rules r where r.component_id = c.id and c.project_id = p.id and r.id in (select distinct rule_id from reviews where user_id is null) order by c.id;
-
Figure out which user ids you want to place on which components by querying the users table.
-
Update the Reviews records with appropriate user ids:
update reviews set user_id = YYY where user_id is null and rule_id in (select id from base_rules where component_id in (ZZZ));
Replacing "YYY" and "ZZZ" appropriately. That will replace all rules under a given component where the user id is null - if needing to do it per rule, other more granular queries would be needed.