[1.7.x] Fixed #23872 -- Removed sensitivity of migrations tests to CWD.

Backport of 47b7f601eeb93bd7a91f87b77da658212f2f2314 from master.