Mapping legacy id to Drupal nid

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
bkildow's picture

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

bkildow's picture

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

vwX's picture

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()

nrambeck's picture

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.

Central Ohio

Group categories

Topics

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week