[1.7.x] Fixed migrations tests added in refs #23315.

Backport of d1299fce0e from master