Refactering migration script