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.
// 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);

Comments

emilorol’s picture

It took me some time to wrap my head around the version described above and I end up writing it up like if working with nodes.

/**
   * Let's bring the comments in
   */

  $comment_arguments = array(
    'ArticleComments' => array(
      'description' => t('Import Drupal 6 article comments'),
      'source_type' => 'article',
      'destination_type' => 'page',
      'node_migration' => 'Article',
    ),
    'NewsComments' => array(
      'description' => t('Import Drupal 6 news comments'),
      'source_type' => 'news',
      'destination_type' => 'news',
      'node_migration' => 'News',
    ),
    'BlogComments' => array(
      'description' => t('Import Drupal 6 blog comments'),
      'source_type' => 'blog',
      'destination_type' => 'blog',
      'node_migration' => 'Blog',
    ),
    'PageComments' => array(
      'description' => t('Import Drupal 6 page comments'),
      'source_type' => 'page',
      'destination_type' => 'page',
      'node_migration' => 'Page',
    ),
  );

  // Use another layer of common arguments to reduce duplication
  $common_comment_arguments = $common_arguments + array(
    'user_migration' => 'User',
    'default_uid' => 0,
    'class_name' => 'DrupalComment6Migration',
  );


  foreach ($comment_arguments as $migration_name => $arguments) {
    $arguments = array_merge_recursive($arguments, $common_comment_arguments);
    $api['migrations'][$migration_name] = $arguments;
  }

Thank you for this great module.

Emil Orol
"In the computer business you’re either a one or a zero and I am determined never to be zero."