Refactor migrations