Use diff based updating for project_authorizations
User#refresh_project_authorizations essentially takes these steps:
- Start a transaction
- Remove existing rows for a user
- Insert all fresh rows for a user
This can lead to a high amount of dead tuples whenever users with access to many projects have their list updated.
To deal with this we should change this method so that it:
- Only removes rows for which access was removed, or for which the access level was changed
- Only inserts rows for which access was granted, or the access level was changed
This means that if user A is granted access to project B only 1 new row is added, instead of X rows being removed and Y new rows being inserted.