In lib/tasks/sync_accounts.rake
Initial situation:
- User 1 in B001
- User 2 in A001
What we want to sync:
- User 1 in A001
- User 2 in B001
Because we loop on users in ID number, we will set User 1 room to A001 first, which will break the unique constraint.
We can replace our unique index with a unique constraint that is DEFERRABLE, then configure in the transaction that we want to delay constraint validation.