Migrating content from Drupal 6 to Drupal 6 (part 1 of ?)

May 22nd, 2012  |  Published in drupal


I’ve got to move some user profiles, feeds and posts from one Drupal 6 site to another. That came with some frustrations. This should not be read as a lot of crowing, because the work isn’t done. A few things worth noting, though, that I’m putting here to help anyone who’s found some excellent tutorials from ca. 2010 and wonders why on Earth they are not working.


The Migrate module provides a very complete API for handling this sort of thing. Migrate v1 provided a number of GUI tools for managing field mappings, rolling back migrations, etc. Migrate v2 is much more complex, offers little in the way of GUI setup, and has proved over complex for what I’m trying to do, which is move nodes between two sites on the same MySQL server.

Migrate v1 uses Table Wizard as a data source for incoming nodes. There’s a great tutorial by Angie “webchick” Byron on Lullabot’s site, but it may prove frustrating until you realize it’s for people using Migrate v1, which you can download here. To support CCK fields and a few other things, you’ll also want migrate_extras for the v1 module.

Once you have those things, the tutorial will make a lot more sense and I have just a few more things to add:

MySQL Views and TableWizard

For Drupal-to-Drupal migrations, you’ll also need to set up your databases with a little more care. In my case, each site has a database sitting on the same MySQL server. To bring content from the incoming database into the receiving site, you’ll have to let Drupal on the receiving site know about it. Adding a line like this in settings.php for the receiving site will do it:

$db_url['db_for_source_site'] = 'mysqli://user:pass@database_host/database_name'; 

Since you’re using a pair of Drupal databases that probably have the same table names, if you haven’t prefixed your table name this will probably bother TableWizard. The quick way around that is to use MySQL views to effectively rename the tables on the incoming site. Here, for instance, is a query to make a MySQL view to provide all your incoming site’s node data to the receiving site. It will appear to Table Wizard as if you have a table called “foo_node.”

create view foo_node AS SELECT * FROM node 

Table Wizard will then allow you to create relationships between your incoming tables using these views. If you don’t take this step, the views generated by Table Wizard will be disagreeable. You might be tempted to bypass the creation of views and simply make sure your Table Wizard default views are named with unique names that won’t collide with existing tables. That didn’t work for me. Take the five seconds each to make views for the tables you need.

Leave a Response

© Michael Hall, licensed under a Creative Commons Attribution-ShareAlike 3.0 United States license.