I run migrations from CSV using Migrate Source CSV, Migrate Plus and Migrate Tools modules and it works fine.
The result of one of these migration is a custom entity which key is a 'id' field that has the 'AUTO_INCREMENT' property in the database.
Here is my migration_contractssubscriptions.yaml

id: migration_contractssubscriptions
migration_group: null
label: 'Contract Subscriptions migration from CSV'
  plugin: csv
  path: /mypathto/migration_ContractsSubscriptions.csv
  delimiter: ';'
  enclosure: '"'
  header_row_count: 1
    - id
  id: id
  contract_id: contract_id
  member_id: member_id
  sharedwith_member_id: sharedwith_member_id
  comment: comment
  quantity01: quantity01
  quantity02: quantity02
  quantity03: quantity03
  quantity04: quantity04
    plugin: default_value
    default_value: 1
  plugin: 'entity:contract_subscription'

I'd like to get rid of 'id' in my csv file and let the migration process handle the value of the resulting id.
I tried to remove keys: - id and id: id but I get an error...
How can I achieve that?

  • I assume id is the primary key of your custom entity, so simply removing process: id: id should work. Do not remove or change fields from source: keys: in production - Migrate's internal mapping table would get out of sync. If you change the source keys, rollback and drop the mapping table first. Look for migrate_map_FOOBAR tables in your DB.
    – Hudri
    Dec 6, 2019 at 16:29
  • Once removed id: id from process: I have this error: [error] La migration a échoué avec l'exception de plugin source : id is defined as a source ID but has no value.
    – gbmapo
    Dec 6, 2019 at 22:06

1 Answer 1


I finally understood that keys in source is the way to make each row of the csv file unique. It may be anything.
So I changed to:

    - contract_id
    - member_id

I removed id: idfrom processand it works!
The value of id field in the database is properly auto-incremented.

  • how do you deal with the required source:ids key then ?
    – Pauleau
    Apr 12, 2022 at 14:16
  • I'm not sure to understand your question :-( As said in the answer, the source keys is made with contract_id and member_id.
    – gbmapo
    Apr 12, 2022 at 15:59
  • I had an error saying that the ids key was required but not given. But it may be caused by something else as your code works today. ty
    – Pauleau
    Apr 13, 2022 at 11:57

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.