I'm trying to update Medias already existing in my Drupal using Migrate and the process entity_lookup.
The field field_uuid was designed specifically as a matcher for my .json original datas and the already imported Medias. The process inside my .yml migration file looks like this :

    plugin: entity_lookup
    source: uuid
    entity_type: media
    bundle: audio
    value_key: field_uuid
    ignore_case: true

I'm working on a specific environment for my developments, and on a different environment for my production version. During my tests on development environment, Medias were updated correctly, without any error raised by Drush and datas were correctly imported.
During the real run on production environment, the process failed with an SQL error raised :

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'edd3a673-dcc7-486c-9e13-bbe982372861' for column `gdrv_media_r0422`.`migrate_map_vyv_dam_document_to_media_reprise`.`sourceid1` at row 1: INSERT INTO "migrate_
  map_vyv_dam_document_to_media_reprise" ("source_ids_hash", "sourceid1", "source_row_status", "rollback_action", "hash") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3,
  :db_insert_placeholder_4); Array
      [:db_insert_placeholder_0] => 6535a5a27e77dc56983baaa4f28952d6d8b8647a973c9366a012e3a65a2c4cb4
      [:db_insert_placeholder_1] => edd3a673-dcc7-486c-9e13-bbe982372861
      [:db_insert_placeholder_2] => 3
      [:db_insert_placeholder_3] => 0
      [:db_insert_placeholder_4] =>

In my understanding, the process entity_lookup seems to fail to find the mid of the media which contains the uuid edd3a673-dcc7-486c-9e13-bbe982372861 and by default try to insert into sourceid1 the value given in the entry (field sourceid1 is an int(11)).
But this happens only in production environment, in which the Drupal is the exact same as development environment (Drupal, MariaDB, Drush, Migrate versions are the same in both environments). But there is in fact a Media which contains this specific value in its field field_uuid, so the entity_lookup should have found a match.
I run the migration using this command in a shell :

./drush mim --tag=media_reprise --update

Does anyone have any idea or hint or solution that can explain the different behavior between my development and production environment ?

  • Did you change source key columns in your migrate.yml? The migrate module does not update existing mappings or the existing mapping table structure when you change the key fields in the source section.
    – Hudri
    Feb 1, 2023 at 12:25
  • When I run my migration, there is no existing mapping table in my database. Migrate create its own table on the first run, whith the elements in the migrate.yml file.
    – CanardPpc
    Feb 1, 2023 at 13:51


Your Answer

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

Browse other questions tagged or ask your own question.