[1.7.x] Fixed #23418 -- Fail when migration deconstruct produces invalid import

Backport of d28b5f13b3 from master