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?

1 Answer 1

0

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

2
  • 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
    Commented Nov 21, 2016 at 2:09
  • 1
    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
    Commented Dec 4, 2016 at 16:48

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.