0

I'm trying to migrate from a SQL table using migrate module. The fields in the table are a unique file hash (media), an url, a drupal internal path. In the class extending SqlBase I have this function:

  public function getIds() {
    // The row property that represent the unique id for the id map.
    $ids['media'] = array(
        'type' => 'integer',
        'alias' => 'm');
    return $ids;
  }

It seems that migrate only accepts integers and requires ids to fill its migration map. Is there a way to migrate with a string hash or without any id?

0

You do have to have an ID - and you can use your hash here simply by defining it with 'type' => 'string'.

  • If I do this I get PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'my_unique_string' for column 'sourceid1' at row 1 This is because it tries to insert the string in sourceid1 field in migrate_map_mymigrationid table, which is a INT field – Angus Nov 21 '16 at 2:09
  • Fixing getIds() to make the ID a string does not rewrite the existing map and message tables - you need to drop them so they'll get regenerated with the right (string) schema. – Mike Ryan Dec 4 '16 at 16:48

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.