Backport commit to add types to references calls in migrations

This is a backport from master to support types in references calls in migrations.