SONAR-4996 Improve migrations by selecting only ids