[1.7.x] Fixed #23560 -- Fixed MigrationWrite to handle builtin types without imports.

Thanks Tim Graham for the review.

Backport of b23d47412c from master