0

I'm building a migration from d6 to d7. I have roles and taxonomies working, but my user import fails. My user migration class is an extension of DrupalUser6Migration.

drush ma shows:

Auditing migrations
ClickUser addFieldMapping: is_new was previously mapped from , overridden                                                                                                                                                             [warning]
ClickUser
No problems found.

drush mi shows:

drush mi ClickUser
ClickUser addFieldMapping: is_new was previously mapped from , overridden                                                                                                                                                             [warning]
Processed 947 (1 created, 0 updated, 0 failed, 946 ignored) in 3.3 sec (18/min) - done with 'ClickUser'  

There are no messages for this migration. I don't know why only one user is being migrated. That one user is coming over great.

Thanks in advance for any help given.

Adding my implementation to aid in assistance.

<?php
/**
* Register all D6->D7 migrations.
*/
require_once('taxonomy.inc');


function clickMigrate_register_migrations() {
/**
 * Each migration being registered takes an array of arguments, some required
 * and some optional. Start with the common arguments required by all - the
 * source_connection (connection key, set up in settings.php, pointing to
 * the Drupal 6 database), source_version (major version of Drupal), and
 * group_name (a.k.a. import job).
 */
$common_arguments = array(
        'source_connection' => 'click2',
        'source_version' => 6,
        'group_name' => 'click',
);


$role_arguments = $common_arguments + array(
    'machine_name' => 'Role',
    'description' => t('Import Drupal 6 roles'),
);
Migration::registerMigration('DrupalRole6Migration', $role_arguments['machine_name'], $role_arguments);

 /*
  * User Picture Migration
  */
  $picture_arguments = $common_arguments + array(
  'machine_name' => 'UserPicture',
  'description' => t('some description'),
  'default_uid' => 1, // The default owner id if owner is not present
  'source_dir' => 'sites/default/files',
  'destination_dir' => 'sites/default/files',
  );
 Migration::registerMigration('DrupalPicture6Migration', $picture_arguments['machine_name'], $picture_arguments);



// The description and the migration machine name are also required arguments,
// which will be unique for each migration you register.
$user_arguments = $common_arguments + array(
        'description' => t('Migration of users from Drupal 6'),
        'machine_name' => 'ClickUser',
        'role_migration' => 'Role',
        'picture_migration' => 'UserPicture',
);

Migration::registerMigration('ClickUserMigration', $user_arguments['machine_name'],$user_arguments);


global $vocabs;
foreach ($vocabs as $vocab){
    //$vocab['machine_name'] = $vocab['source_machine_name'];
    $vocabulary_arguments[] = $vocab;
}

$common_vocabulary_arguments = $common_arguments + array(
        'class_name' => 'DrupalTerm6Migration',
);
foreach ($vocabulary_arguments as $arguments) {
    $arguments += $common_vocabulary_arguments;
    Migration::registerMigration( $arguments['class_name'], $arguments['machine_name'],$arguments );
}

                      $menu_links_arguments);
}

 <?php
 class ClickUserMigration extends DrupalUser6Migration{
public function __construct(array $arguments) {
    $this->dependencies[] = 'Role';

    $this->sourceFields['field_contact_twitter'] = '';
    $this->sourceFields['field_contact_alternate_phone'] = '';
    $this->sourceFields['field_firstname'] = '';
    $this->sourceFields['field_contact_linkedin'] = '';
    $this->sourceFields['field_phone'] = '';

    $this->sourceFields['field_title'] = '';
    $this->sourceFields['field_department'] = '';
    $this->sourceFields['uid'] = '';
    $this->sourceFields['field_contact_type'] = '';
    $this->sourceFields['field_contact_primary_cont'] = '';
    $this->sourceFields['field_contact_image'] = '';
    $this->sourceFields['field_contact_image:list'] = '';


    parent::__construct($arguments);

    $this->addFieldMapping('is_new')->defaultvalue(TRUE);
    $this->addFieldMapping('uid', 'uid');
    $this->addFieldMapping('field_first_name', 'field_firstname');
    $this->addfieldMapping('field_first_name:language')->defaultValue('en');
    $this->addFieldMapping('field_last_name', 'field_lastname');
    $this->addfieldMapping('field_last_name:language')->defaultValue('en');


    $this->addFieldMapping('field_twitter', 'field_contact_twitter');
    $this->addFieldMapping('field_alternate_phone','field_contact_alternate_phone');
    $this->addfieldMapping('field_alternate_phone:language')->defaultValue('en');
    $this->addFieldMapping('field_user_linkedin','field_contact_linkedin');
    $this->addfieldMapping('field_user_linkedin:title')->defaultValue('');
    $this->addfieldMapping('field_user_linkedin:attributes')->defaultValue('');
    $this->addfieldMapping('field_user_linkedin:language')->defaultValue('en');
    $this->addFieldMapping('field_user_phone','field_phone');
    $this->addfieldMapping('field_user_phone:language')->defaultValue('en');
    $this->addFieldMapping('field_user_title','field_title');
    $this->addfieldMapping('field_user_title:language')->defaultValue('en');
    $this->addFieldMapping('field_user_department','field_department');
    $this->addfieldMapping('field_user_department:language')->defaultValue('en');
    $this->addFieldMapping('field_user_contact_type','field_contact_type');
    $this->addFieldMapping('field_primary_contact','field_contact_primary_cont');


    $this->addUnmigratedSources(array('field_contact_image', 'field_contact_image:list', 'field_contact_member_company','field_contact_linkedin:title','field_contact_linkedin:attributes','field_contact_twitter:title','field_contact_twitter:attributes'), t('Do Not Migrate'));



}
/**
 * Implementation of Migration::prepareRow().
 *
 * @param $row
 */
public function prepareRow($row) {
    if (parent::prepareRow($row) === FALSE) {
        return FALSE;
    }

    /**
     * Note that the date module adds a timezone_name column to the users table,
     * so if present we can use that directly. Otherwise, we do as the D6->D7
     * upgrade does and just clear it - let users reset their timezones in the
     * D7 site.
     */
    if ($row->uid == 1) {
        return FALSE;
    }
}

}
class FileMigration extends DrupalFile6Migration {
public function __construct(array $arguments) {
    parent::__construct($arguments);
    $this->addFieldMapping('destination_file', 'filename');
}
 }
  • Could you post the full migration implementation? – Les Lim Nov 16 '13 at 4:51
  • i updated my post with the code, let me know if you need more – tara Nov 16 '13 at 19:14
  • I don't see anything obviously wrong. If you attempt registering DrupalUser6Migration directly instead of ClickUserMigration, does that result in more created users? – Les Lim Nov 16 '13 at 22:51
  • Thanks for the suggestion, unfortunately it gave the same results. It was the same user migrated (1 of 947). The only difference is that the uid of the user in the destination. With my class, uid was preserved. With the default class it was 2. – tara Nov 17 '13 at 2:20
  • Hmm. Do your 947 source users have unique email addresses? There's some deduplication code in the migrate_d2d user class to match migration rows to existing user accounts if the email address is the same. – Les Lim Nov 17 '13 at 6:43
0

Based on what we discovered in the comments to this question, the migrate_d2d.module's DrupalUserMigration class does some de-duplication to make sure that it's not creating users with the same email addresses as existing users. It skips source rows if the "mail" value matches that of an existing D7 user.

  • Thanks Les. It is interesting that the one user copied over is about three quarters of the way through the pack (uid 599) . I would have expected the first as all others were dupes of that. – tara Nov 18 '13 at 13:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.