Move imports into migrate().

It's not very PEP8 compliant, but it results in fewer lines with increased
clarity.