Add algorithm to update country preferences.

This implements the country assignment update algorithm in #261.
It goes through each row in the new country assignments, and queues
additions or deletions as necessary. At the end, it executes them
in a transaction.

**Test Plan:** Added a unit test with cases for addition, update,
and deletion.