Hi, I'm trying to import comments form drupal6 to drupal7.

Using migrate_d2d_example I came up with that code (there is no example of importing comments in that file):

migrate_d2d_example.module:

function migrate_d2d_example_register_migrations() {
...
$arguments = $common_arguments + array(
    'class_name' => 'ExampleCommentMigration',
    'description' => t('Migration of comments from Drupal 6'),
    'machine_name' => 'Comments',
    'source_type' => 'blog',
    'destination_type' => 'article',
  );
  Migration::registerMigration('ExampleCommentMigration', $arguments['machine_name'],
                               $arguments);
... }

node.inc:

class ExampleCommentMigration extends DrupalComment6Migration {
  public function __construct(array $arguments) {
    parent::__construct($arguments);
    $this->addFieldMapping('uid', 'uid');         
  }
  public function sourceFieldList() {
    $fields = parent::sourceFieldList();
    return $fields;
  }
}

System see migration, find rows in drupal6 database, import without errors, imported comments in drupal7 db have all fields filled but when i go to admin/content/comment there are no comments. Also there is no comments in nodes. I think that I missed something but can't figure out what.

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Try adding a 'node_migration' argument, pointing at the migration creating your article nodes, so the comment migration can proper populate the nid. Also, pass a 'user_migration' argument rather than mapping the uid directly.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

marcus178’s picture

Version: » 7.x-2.0-rc1

This seems to work for me

	$comment_arguments = array(
		array(
			'class_name' => 'ArtistsCommentsMigration',
			'description' => t('Migration of artist comments from Drupal 6'),
			'machine_name' => 'ArtistComments',
			'source_type' => 'artists',
			'destination_type' => 'artists',
		),
	);
	$common_comment_arguments = $common_arguments + array(
		'user_migration' => 'User',
		'node_migration' => 'ArtistNodes',
	);
	foreach ($comment_arguments as $arguments) {
		$arguments = array_merge_recursive($arguments, $common_comment_arguments);
		Migration::registerMigration($arguments['class_name'], $arguments['machine_name'],
			$arguments);
	}
naught101’s picture

Status: Closed (fixed) » Active

This is not working for me. I'm using approximately the above code, and my migrations end up looking like this:

Array
(
    [description] => Migration of Story comments from Generic D5
    [machine_name] => CommentStory
    [source_type] => story
    [destination_type] => article
    [dependencies] => Array
        (
            [0] => Story
        )

    [node_migration] => CommentStory
    [source_connection] => legacy
    [source_version] => 5
    [class_name] => DrupalComment5Migration
    [user_migration] => User
)

The node migrations ARE working, but for every comment, I get "No node ID provided for comment" errors. Any ideas?

My code is here: http://drupalcode.org/sandbox/naught101/1655440.git/commitdiff/0a036a711...

I've tried with and without the field_legacy_nid from the example module, and asked for clarification here: #1943880: What is field_legacy_nid for?

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

This definitely looks wrong:

[node_migration] => CommentStory

I'm imagining the parent node migration is named "Story", so that's what you should be setting here.

naught101’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Ha, nice catch. I was stupidly setting the machine name backwards. Works now, although it imports comments as unapproved. I'll have another play with it, and see where I get. Thanks, Mike!

naught101’s picture

Status: Closed (fixed) » Active

Soo... the D6 comment source has a `handleStatus()` method, that basically duplicates `comment_update_7001()`, except that it doesn't handle statuses > 1 properly (assume this code is in `comment_update_7001` to not screw with custom modules that use their own statuses. Should this code be updated to reflect the `comment_update_7001` code?

I am still working on the D5 version, so I am happy to write either a D5 patch replicating the D6 source code, or one for D5 and D6, to fix the above issue, but I'm not sure whether it's worth it?

naught101’s picture

Status: Active » Needs review
StatusFileSize
new1.56 KB

Here we go. Works for me on D5.

mikeryan’s picture

Status: Needs review » Closed (fixed)

Reverting issue back to its original state - the recent comments have nothing to do with the original issue other than having something to do with comments. Different issues should have different (drupal.org) issues.

kochertj’s picture

Version: 7.x-2.0-rc1 » 7.x-2.1-beta1
Issue summary: View changes
Status: Closed (fixed) » Active

I am running a Drupal6-to-Drupal7 migration. I am using the Commentforum task built into the migrate_d2d and migrate_d2d_ui modules in d6/comment.inc and d7/comment.inc.

I am using Migrate 7.x-2.6-rc1 and Drupal-to-Drupal migration 7.x-2.1-beta1+8-dev.

The source query displays as...

SELECT c.cid AS cid, c.pid AS pid, c.nid AS nid, c.uid AS uid, c.subject AS subject, c.comment AS comment, c.hostname AS hostname, c.timestamp AS timestamp, c.status AS status, c.thread AS thread, c.name AS name, c.mail AS mail, c.homepage AS homepage, c.format AS format
FROM
{comments} c
INNER JOIN {node} n ON c.nid = n.nid
WHERE (n.type = :db_condition_placeholder_0)
ORDER BY timestamp ASC

I keep on getting this message "Error: No node ID provided for comment". Any ideas why this comment migration is failing?

Chetan Sharma’s picture

I want to migrate comment of particular content type from drupal 6 to drupal 7.
Can anyone help me to achieve this.

mikeryan’s picture

Status: Active » Closed (fixed)

Please do not reopen long-closed issues, or add new questions to an issue just because they both have to do with comments - please open new issue and make your questions as specific as possible.