0

I'm getting some really strange behavior with my custom migration class where the map tables are all being put into the legacy (6) database rather than the destination (7) database. This happens for all of my custom migration classes and not the ones using d2d. I believe it has something to do with my $this->map in the migrations with the final argument being 'legacy' or possibly it's the $query = Database::getConnection('default', 'legacy') part of the migration.

My custom class for term migration does import the data into the new site from the old correctly, but the map tables are still going to the legacy database.

I've found a few sources of others having issues getting multiple databases to work in a migration but they seem to be conflicting with each other.

Here is my class:

class myUserProfileMigration extends myMigration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this->arguments = $arguments;

    $this->description = t('My User Profiles Migration');

    $dependencies = array(
      'User'
    );

    $this->dependencies = $dependencies;

    $query = Database::getConnection('default', 'legacy')
          ->select('node', 'n');
    $query->condition('n.type', 'person_profile_page', '=');
    $query->join('users', 'u', 'u.uid = n.uid');
    $query->fields('u', array('name', 'uid'));
    $query->fields('n', array('uid', 'nid'));
    $query->join('content_type_person_profile_page', 'p', 'p.nid = n.nid');
    $query->fields('p', array(
      'field_about_me_value',
      'field_likes_value',
      'field_dislikes_value',
      'field_google_plus_value',
      'field_twitter_handle_value',
    ));

    $this->source = new MigrateSourceSQL($query);

    $this->destination = new MigrateDestinationUser();

    $this->addFieldMapping('uid', 'uid')
         ->sourceMigration('User');
    $this->addFieldMapping('field_likes', 'field_likes_value');
    $this->addFieldMapping('field_dislikes', 'field_dislikes_value');
    $this->addFieldMapping('field_about_me', 'field_about_me_value');
    $this->addFieldMapping('field_about_me:format')
         ->defaultValue('filtered_html');
    $this->addFieldMapping('field_google_id', 'field_google_plus_value');
    $this->addFieldMapping('field_twitter_handle', 'field_twitter_handle_value');

    $source_key = array(
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'Original Author UID',
        'alias' => 'n',
      )
    );
    $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationUser::getKeySchema(), 'legacy');

  }

}

And here is my settings.local.php:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'dest_db',
      'username' => 'root',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
  'legacy' =>
  array(
    'default' =>
    array(
      'database' => 'legacy_db',
      'username' => 'root',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);
2

Read up on the documentation on Map Tables under the heading Map Tables on that page. If you define legacy as the connection to make the map tables on -- then that's where they will go.

When you construct the MigrateSQLMap object, add a fourth argument to tell it explicitly the connection on which to create the mapping tables.

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.