Optimize migrations.

Change-Id: I61de50cc25d19ec75de582419e1f90a44668f3f2