2

I'm looking for a content and data migration module.

Which are commonly used?

1
  • 1
    Try google before post.
    – niksmac
    Apr 21 '12 at 7:23
0

Try

Backup and Migrate

Migrate

Related projects

Migrate Extras

Migrate Drupal

0

It depends on what you're looking for, but unless you are working on an enterprise-level site, my experience is that it will be faster to do the migration manually without using helper modules.

While the Feeds and Migrate modules are probably the most common approaches, they are difficult to configure and manage due to the large number of possible use cases that must be dealt with. For example, if you look at the backers of the Migrate module, the credits include PayPal, the World Economic Forum, Warner Music, and other similarly large organizations.

1
0

I learned the hard way what Patrick kenny is saying. I spent 1 day finding modules, trying to configure them and I was not able to do it. I had 500 + records which I needed to create drupal nodes. These were nodes with custom fields and file attachments. I created a database and populated it with the raw data then I wrote a script to get each row and add it to drupal database. I placed the pdf file attachements in the required folder.It took me only two hours to do all this. Script is as follows.

 //connect database with raw data
$pub_link = mysql_connect('127.0.0.1', 'root', 'root');
if (!$pub_link) {
    die('Could not connect: ' . mysql_error());
}

//connect drupal database
$drupal_link = mysql_connect('127.0.0.1', 'root', 'root');
if (!$drupal_link) {
    die('Could not connect: ' . mysql_error());
}

// get each row

$number = 1;
while ($number < 576) {
//get the content  
    mysql_select_db("raw_database_name", $pub_link);
    $pr_result = mysql_query('SELECT * FROM pub WHERE id =' . $number);
    $pr_row = mysql_fetch_assoc($pr_result);

    $pub_id_one = $pr_row['id'];
    $pub_id = mysql_real_escape_string($pub_id_one);
    $pub_author_one = $pr_row['author'];
    $pub_author = mysql_real_escape_string($pub_author_one);
    $pub_title_one = $pr_row['title'];
    $pub_title = mysql_real_escape_string($pub_title_one);
    $pub_ab_one = $pr_row['ab'];
    $pub_ab = mysql_real_escape_string($pub_ab_one);
    $pub_year = $pr_row['year'];
    $pub_pubid = $pr_row['pubid'];

//insert the content
    mysql_select_db("drupal_database_name", $drupal_link);
//get the existing node id +1 for next nodeid to insert
    $result = mysql_query('SELECT MAX(nid)+1 FROM node');
    $nid = mysql_result($result, 0);
//get the existing node_revision id +1 for new node_revision id    
    $result = mysql_query('SELECT MAX(vid)+1 FROM node_revisions');
    $vid = mysql_result($result, 0);
//get the existing fid for files +1 for new fid    
    $result = mysql_query('SELECT MAX(fid)+1 FROM files');
    $fid = mysql_result($result, 0);
//check if fields are not empty run the script to enter the data.    
if($pub_title !="" and $pub_ab != ""){
    mysql_query('INSERT INTO  node_revisions  (vid, nid, uid, title, body, teaser, timestamp, format)  VALUES (\'' . $vid . '\', \'' . $nid . '\', 1, \'' . $pub_title . '\', \' \', \'\', now(), \'2\');');
    mysql_query('INSERT INTO content_type_name (vid, nid, field_field_name_value, field_field_name_format, field_pub_date_value, field_pub_file_fid, field_pub_file_list, field_pub_type_value, field_pub_sri_value, field_pub_note_value, field_pub_note_format) VALUES(\'' . $vid . '\', \'' . $nid . '\', \'' . $pub_ab . '\', 2 , \'' . $pub_year .'T00:00:00\', \''.$fid.'\', \'1\', "journal", 1, \''.$pub_author.'\', 2);');
    mysql_query('INSERT INTO node (  vid, nid, type, title, uid, status, created) VALUES (\'' . $vid . '\', \'' . $nid . '\', \'publication\', \'' . $pub_title . '\', 1, 0, now());');
    $query_four = 'INSERT INTO files (fid, uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (\'' . $fid . '\', \'1\', \'' . $pub_pubid.'.pdf \', \'sites/default/files/uploads/publications/pdf/' . $pub_pubid.'.pdf\', \'application/pdf\', \'160000\', \'1\', \'1331410502\')';

    mysql_query($query_four);
mysql_query('INSERT INTO workflow_node (  nid, sid, uid, stamp) VALUES ('.$nid.', "8", "1", "1327964040");');
}else{
    print $number."not set";
}
print'</br>';
    $number++;
}
print 'Done go and check it now  >>> ';
mysql_close($pub_link);

mysql_close($drupal_link);
0

At least migrate has the option to import a CSV or XML file.

If you have the option to export the file, then importing will not be more difficult than the code example here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy