bug fixes

This fixes some bugs in migrate with -o (reported by Mark Christian).  There are two commits here; the first just hardens the script a bit by quoting variables and crashing out on error better.  The second actually does the fixes.

Testing Done:
Tested by migrated macaw-swift from twitter into birdcage.

Bugs closed: DPB-1796

Reviewed at https://rbcommons.com/s/twitter/r/792/