Drupal 4.7 migration to Drupal 7 - Books - Part 3

This is the third installment of my saga of upgrading my Drupal 4.7 internal knowledgebase to Drupal 7.

I had chosen to investigate the Migrate & d2d modules and had some promising early success. My next challenge was restoring my "books". Similar to the "<Previous" "Next>" links on this blog and the book hierarchy on Drupal.org my knowledgebase utilized structured content via Books. And I was attached to that meme.

A quick google search indicated that d2d did not provide native support for books. And that migrating books was declared to be complex.

Based upon my prior Feeds experience with importing Comments, I understood the concept of "early child". If a child node (comment) shows up before it's parent then you are in trouble. What to do with the child? You have no parent to attach it to. Note that I am using a conceptional model where I did not wish to retain nids or cids across the migration.

Simplest solution is to ignore the early child until it has a parent. This dictates a multi-pass import. How to do this?

Time to invoke custom code! I had to make some configuration changes AND hack the d2d d5 node.inc file to provide some "fixes". This effort included:

  • enabling the book module on my new site (why is it not part of a standard install?)
  • altering the source query to include book id (bid) information
  • detecting an "early child" (book parent not imported yet) and aborting that record
  • using the Migrate update option to perform multiple passes

These tweaks gave me a perfectly replicated book hierarchy. But no attached files.

My next post will highlight some of the challenges of getting my files attached to the proper nodes.