[1.7.x] Fixed #22749: Making SQL management commands migration aware.