There are many ways to trick this cat, several methods that I can think of:
1. Removing all roles and reinstalling
This is a direct approach. Remove all roles for the user and simply reinsert. Typically, the user applies to only a few roles (less than 10). In addition, there is a good chance that no other foreign keys will contact this many-to-many table.
2. Keep track of changes and apply only changes
This works more, but more efficiently, even if a little in this case. Tools such as ORMs allow you to track and apply these types of changes.
3. Apply changes when user made changes
In this case, I assume that it is acceptable to apply database changes since the end user associates the user with roles. Perhaps this is a local database, and each transaction is short-lived. But I guess this is an unlikely scenario.
I do not think that in this particular case there is something wrong for uninstalling and reinstalling.
Philip fourie
source share