Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set id of CSV migration row based on line number #10

Open
eiriksm opened this issue Jul 5, 2020 · 4 comments
Open

Set id of CSV migration row based on line number #10

eiriksm opened this issue Jul 5, 2020 · 4 comments

Comments

@eiriksm
Copy link
Owner

@eiriksm eiriksm commented Jul 5, 2020

https://eiriksm.dev/set-id-csv-migration-row-number

@DLatty-NJT
Copy link

@DLatty-NJT DLatty-NJT commented Mar 19, 2021

Why is ID mandatory? What if i just want it auto-incremented? Seems there will be many collisions if you are required to specify. For certain data, I simply want the next available ID and on. Would I really have to write code to get the first node desc id - in order to do this? Seems like ids[] or similar should be a function.

@eiriksm
Copy link
Owner Author

@eiriksm eiriksm commented Mar 19, 2021

👋 Thanks for commenting!

The id in question is the migration row Id. In the article it has no relationship to the node id. You have to have a migration row Id to be able to re-run migrations and only migrate changes, for example. Sorry if that was not clear 😬🤓

@batigolix
Copy link

@batigolix batigolix commented Feb 28, 2022

I am using drupal 9.3 & migrate_plus 5 and I cannot get this working. Do the examples in your blog work with the most recent versions?

I had to changed "keys" for "ids".:
You must declare "ids" as a unique array of fields in your source settings.
This may be because of recent changes in the csv source plugin or drupal 9 core migrate.

Also the ID you set in prepareRow() is not recognized. The migration fails before prepareRow() because it looks for a ID column in the CSV :

[error] Migratie mislukt met bronplugin-melding: 'my_id' is defined as a source ID but has no value. in /var/www/html/web/core/modules/migrate/src/Row.php regel 107
(apologies for the partial dutch message)

@eiriksm
Copy link
Owner Author

@eiriksm eiriksm commented Mar 2, 2022

I see. This was indeed tested on earlier versions so I would have to look at it again when I get the time, to update the article. If you find out what changed in the meantime, it would be fantastic if you are able to share that! 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants