drupaldata-migrationmigrate

migrating node references


I am working on a project to migrate a website from asp.net to drupal architecture. But the site content is very hierarchal and has a lot of references between entities.

for example: each content belongs to a category, and each category belongs to another category section. Now there may be another level of hierarchy even.

I am planning to make use of migrate module for migrating the database content and linking the migrated nodes via a node reference field.

But i am getting stuck with migrate module as i can't find a way to migrate the node reference field anywhere...

can anyone help me out with this...


Solution

  • As far as I know, you will not be able to do this entirely within the migrate module. You'll have to run a few queries directly in MySQL.

    Essentially, you'll have to create an extra field in each content type to house their legacy ID's and an additional field for each legacy reference (in addition to the actual nodereference field). Load all the data into the content types (leave the nodereference field empty). Then once all of the entities are loaded in, you run mysql queries to populate the nodereference fields based on the legacy IDs and legacy reference fields. Once that's done you can safely delete these legacy fields.

    Not the most elegant solution, but I've used it many times.

    Caveats: