speed up the case migration script
refactor based on PR feedback
switch user_id precedence
Merge pull request #630 from dimagi/case-migration

speed up the case migration script