Fixed #22319 -- Fixed migration external dependencies when there are int...

...ernal dependencies.