Fix refactor migration for populated databases