Added flexible migrations to 3.1 branch