speed up the case migration script
refactor based on PR feedback
switch user_id precedence
Merge branch 'case-migration' into staging2