Community Documentation

Comment migration

Last updated April 29, 2013. Created by mikeryan on October 22, 2012.
Log in to edit this page.

Comment migrations are coupled to their corresponding node migrations - for each node type that has comments, you will define a corresponding comment migration.

  • source_type: The unique machine name of the legacy node type.
  • destination_type: The unique machine name of the destination node type.
  • user_migration: The machine name of your user migration, used to properly assign authorship of the comments.
  • default_uid: A default destination uid to use as the default author of nodes where a legacy owner isn't identified (for example, nodes authored by the account with uid 1 in the legacy system, since that account is not migrated).
  • node_migration: The machine name of the migration for the nodes parenting these comments.

<?php
// Use another layer of common arguments to reduce duplication
$comment_arguments = $common_arguments + array(
 
'user_migration' => 'ExampleUser',
 
'default_uid' => 0,
);

$photo_comment_arguments = $comment_arguments + array(
 
'machine_name' => 'ExamplePhotoComment',
 
'description' => t('Import Drupal 6 photo comments'),
 
'source_type' => 'photo',
 
'destination_type' => 'photo',
 
'node_migration' => 'ExamplePhotoNode',
);

Migration::registerMigration('DrupalComment6Migration',
 
$photo_comment_arguments['machine_name'], $photo_comment_arguments);

$video_comment_arguments = $comment_arguments + array(
 
'machine_name' => 'ExampleVideoComment',
 
'description' => t('Import Drupal 6 video comments'),
 
'source_type' => 'video',
 
'destination_type' => 'video',
 
'node_migration' => 'ExampleVideoNode',
);

Migration::registerMigration('DrupalComment6Migration',
 
$video_comment_arguments['machine_name'], $video_comment_arguments);
?>

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Level
Intermediate, Advanced
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.