Migrate is putting map tables in legacy database 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-&gt;arguments = $arguments;

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

    $dependencies = array(
      'User'
    );

    $this-&gt;dependencies = $dependencies;

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

    $this-&gt;source = new MigrateSourceSQL($query);

    $this-&gt;destination = new MigrateDestinationUser();

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

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

  }

}


And here is my settings.local.php:

$databases = array (
  'default' =&gt;
  array (
    'default' =&gt;
    array (
      'database' =&gt; 'dest_db',
      'username' =&gt; 'root',
      'password' =&gt; '',
      'host' =&gt; 'localhost',
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; '',
    ),
  ),
  'legacy' =&gt;
  array(
    'default' =&gt;
    array(
      'database' =&gt; 'legacy_db',
      'username' =&gt; 'root',
      'password' =&gt; '',
      'host' =&gt; 'localhost',
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; '',
    ),
  ),
);
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.