refactor related entities migration