Posted by bkildow on March 29, 2010 at 3:41pm
I'm working on a fairly large migration project. For this project, I will be migrating legacy data into Drupal 6. For this, I would like to create a new node with a specified nid so I can import data and maintain correct paths. I have looked everywhere for any tips on how to accomplish this, however, it doesn't seem like a very common practice. I have considered adding aliases, but for my case, I really feel like if I can directly map legacy ids to drupal nids, it will really make my life easier down the road. Has anybody had success doing anything like this?
Comments
Different Approach
Ok, I think I'm going to take a different approach to this. I'm going to migrate the content in using the tw/migrate module which will create new nids, then create a cck field to hold the legacy ids. Then I am going to use the path_redirect module and some custom coding to bulk load the old URLs to redirect to the new URLs. Hopefully that should work!
redirects
If you have a lot of links, you probably would be better off using a rewrite rule (mod_rewrite using rewritemap or similar) and let the web server handle the load rather than polluting your url_alias table. This will have lower overhead than doing it in drupal.
node_save()
I've done several large migrations and a few Drupal-to-Drupal where we wanted to preserve node IDs. I wrote a script that simply built a new $node object from the source data and used node_save() to save the objects. To preserve node ID's I simply inserted stub node data with the proper into the node and node_revisions tables before executing the node_save(). You can use Drupal's Batch API to keep the process running in the browser or run the script via drush.
--
Nathan Rambeck