Fixes #4849: Adapat migration script so they don't lock much

http://www.rudder-project.org/redmine/issues/4849