When I try migrating my content from one MySQL into my Drupal site using drush, I'm getting the following error:

Migration failed with source plugin exception: SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'isps_wp'@'localhost' for table 'migrate_map_isps'                                                                                [error]

When I give the source database's user all permissions to my Drupal database, the migration works fine. But it seems wrong to me that I would have to give my source database's user permissions to my Drupal db to make this work.

I'm pasting my migrate class below. Are there some obvious things wrong here?

// Migration class.
class IspsMigration extends Migration {
  public function __construct() {
    parent::__construct(MigrateGroup::getInstance('ISPS'));
    $this->description = 'ISPS migration';
    // Use a SQL database as source.
    $query = Database::getConnection('default', 'for_migration')
             ->select('wp_posts', 'wp')
             ->fields('wp', array('id', 'post_title', 'post_content', 'post_type'))
             ->condition('post_type', 'page', '=');
    $this->source = new MigrateSourceSQL($query);
    // We migrate into "article" nodes.
    $this->destination = new MigrateDestinationNode('article');

    // We instantiate the MigrateMap
    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'id' => array('type' => 'int',
                        'unsigned' => TRUE,
                        'not null' => TRUE,
                         )
        ),
        MigrateDestinationNode::getKeySchema()
      );

    // Finally we add simple field mappings 
    $this->addFieldMapping('title', 'post_title');
    $this->addFieldMapping('body', 'post_content');
  }
}

Comments

brunodbo’s picture

Status: Active » Fixed

I'm assuming this has to do with the creation of the migration map table, as mentioned on http://drupal.org/node/1014558 ('Map tables').

Marking as fixed.

mikeryan’s picture

By default, Migrate will try to directly join the source query to the map table, which is (by default) in the Drupal database, as a performance optimization. To disable this behavior:

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

In hindsight, I wish I'd made FALSE the default, but changing the default would affect those depending on getting the join automatically...

mikeryan’s picture

Yep, you found it!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updating description.

kenorb’s picture

kenorb’s picture