TSP-4468 Several bugfixes for automated MySQL migrations