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) {
    $this->arguments = $arguments;

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

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

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

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

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

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



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

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

$databases['legacy']['default'] = array(
  'database' => 'legacy_db_name',
  'username' => 'uname',
  'password' => 'passwd',
  'host' => 'legacy_db_host',
  'port' => '',
  'driver' => 'mysql',
  'prefix' => '',

2 Answers 2


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.


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.


I had an error showing that:

Migration failed with source plugin exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DESTINATION_database_name.migrate_map_migrationname' doesn't exist, in /code/includes/database/database.inc:2171 even though I have checked the database and the table is there... Was hitting my head against the wall for a while .. :)

Adding map_joinable option solved the issue for me:

$this->source = new MigrateSourceSQL($query, $source_fields, NULL, array('map_joinable' => FALSE));

Exception was gone and migration was running normally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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