0

This is a weird issue with the Migrate module 2.6 I'm migrating a users table "mysql" database to a test node and I'm getting a error with the migration map here is the error :

Migration failed with source plugin exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.migrate_map_usersmigration map ON u.user_id = map.sourceid1 WHERE ( (map.source' at line 1

and here is my code:

class UsersMigration extends myBaseMigrationClass {

  public function __construct($arguments) {
    parent::__construct($arguments);

    $this->description = t('Just for testing');

    $query = Database::getConnection('default', 'mydb')
      ->select('users', 'u')
      ->fields('u', array('user_id', 'full_name', 'birthday'));

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

    $this->destination = new MigrateDestinationNode('test');

    $this->map = new MigrateSQLMap(
    $this->machineName,
      array(
        'user_id' => array(
            'type' => 'int',
            'not null' => TRUE,
            'alias' => 'u',
        ),
      ),
      MigrateDestinationNode::getKeySchema()
    );

    $this->addFieldMapping('title', 'full_name');
  }
}

Do I'm doing something wrong here?

  • Also to clarify, the source query is working fine and I'm getting the correct data out when I print it out.
1

Finally I was able to find a solution for this weird issue, according to the Migration examples (beer, Wine) modules. the code I have posted above should work fine, However it's throwing that weird error. it turns out that I needed to pass the database name again like this:

$this->map = new MigrateSQLMap(
$this->machineName,
  array(
    'user_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'alias' => 'u',
    ),
  ),
  MigrateDestinationNode::getKeySchema(),
 'mydbName'
);

even the example modules that using SqlSource class wont work with migrate "7.x-2.6-rc1+57-dev". I will try to report that issue to the developer

0

I was also experiencing this issue.

I tried to do the same actions on another machine. The problem does not occur there, which is very strange. I suspect this is a problem with my LAMP stack (native OS X Mavericks stack).

So it could be your PHP version, try upgrading it.

See Migrate examples failing

1
  • 1
    Hi and welcome to Drupal Answers. Could you please improve your answer by summarizing the key elements of your link. – Wtower Nov 21 '14 at 10:13

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.