Migration is not able to find legacy database tables for some migrations The hosting server I am using is Pantheon.
I'm trying to migrate taxonomy over from D6 to D7 with a custom migration class.  The problem is that I'm getting different behaviors on my local repo and the one  on the server.  On the server, I get an error saying that 


  Migration failed with source plugin exception: SQLSTATE[42S02]: Base
  table or view not found: 1146 Table
  'legacy_database_name.migrate_map_tdmchanneltermparent' doesn't exist, in
  /srv/bindings/3b34ee5b39e94f12ad1de632af512a5b/code/includes/database/database.inc:2171


I'm not sure why it is trying to connect to the legacy database for the map in this migration.

Here is my migration class:

class chalkTermParentMigration extends tdmTermMigration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this-&gt;arguments = $arguments;

    $this-&gt;description = t('Chalk Term Parent Migration');

    $query = Database::getConnection('mig_dest', 'legacy')
      -&gt;select('vocabulary', 'v');
    $or = db_or()-&gt;condition('v.vid', 10)
      -&gt;condition('v.vid', 11, '=')
      -&gt;condition('v.vid', 12, '=')
      -&gt;condition('v.vid', 20, '=')
      -&gt;condition('v.vid', 21, '=')
      -&gt;condition('v.vid', 25, '=');
    $query-&gt;condition($or);
    $query-&gt;fields('v', array('vid', 'name'));

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

    $this-&gt;destination = new MigrateDestinationTerm('chalk');

    $this-&gt;addFieldMapping('name', 'name');
    $this-&gt;addFieldMapping('field_legacy_id', 'vid');

    $source_key = array(
      'vid' =&gt; array(
        'type' =&gt; 'varchar',
        'length' =&gt; 255,
        'not null' =&gt; TRUE,
        'description' =&gt; 'Legacy Vocab ID',
      )
    );
    $this-&gt;map = new MigrateSQLMap($this-&gt;machineName, $source_key, MigrateDestinationTerm::getKeySchema());

  }

}


Here is how I have my legacy database connection information set up:

if (!defined(PANTHEON_ENVIRONMENT)) {
  $databases['mig_dest']['default'] = array(
    'database' =&gt; 'abc',
    'username' =&gt; 'abcdev',
    'password' =&gt; 'qwe123',
    'host' =&gt; 'localhost',
    'port' =&gt; '',
    'driver' =&gt; 'mysql',
    'prefix' =&gt; '',
  );
  $databases['default'] = $databases['mig_dest'];
} else {
  $databases['mig_dest']['default'] = array(
    'database' =&gt; $_ENV['DB_NAME'],
    'username' =&gt; $_ENV['DB_USER'],
    'password' =&gt; $_ENV['DB_PASSWORD'],
    'host' =&gt; $_ENV['DB_HOST'],
    'port' =&gt; $_ENV['DB_PORT'],
    'driver' =&gt; 'mysql',
    'prefix' =&gt; '',
  );
}

$databases['legacy']['default'] = array(
  'database' =&gt; 'legacy_db_name',
  'username' =&gt; 'uname',
  'password' =&gt; 'passwd',
  'host' =&gt; 'legacy_db_host',
  'port' =&gt; '',
  'driver' =&gt; 'mysql',
  'prefix' =&gt; '',
);
legacy_database_name.migrate_map_tdmchanneltermparent is a table typically made by the Migrate module to perform a mapping between source DB data and destination DB data. There is typically migrate_map table(s) and for instance migrate_messages table(s).

Be sure to properly Import or Rollback migrations. If you clearing the database by hand and dropping any of these tables, Migrate can get confused. Sometimes I occassionaly MySQL Truncate these tables by hand during my job workflow, but then you need to be careful and understand what migrate is doing -- how it's mapping processed data or registering migrations.

EDIT:

Then as a work around I suggest following the documentation for Map Tables heading section and explicity define the connection you want the mapping table created on. Since you have what looks like a local test migration setup and a Pantheon setup add this ... = new MigrateSQLMap( ... ); in an IF statement to point to the correct Drupal destination connection name.


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