This is a follow up from #2850309-14: Regenerate config entities when using --config-only multiple times..
I found that once you have exported migration files once using the following command:
drush migrate:upgrade --legacy-db-key=ukids7 --legacy-root=sites/default/files --configure-only
Future runs of the above command (which are needed when you have made changes to the migration files) will keep prefixing upgrade_ to migration files turning out like upgrade_upgrade_d7_dblog_settings.
I discovered that web/core/modules/migrate/src/Plugin/MigrationPluginManager.php::createInstancesByTag() returns not only the core and contrib migrations but also previously exported migrations which are prefixed with "upgrade_". See the following screenshot:

Which then, when exporting configuration, turns into these additional migration files with the upgrade_upgrade_ prefix:

I also found that there is another test in the same class that uses assertEquals(count(), count()) as well so if we change this here we should change it there too for consistency.
Work around
Export config, then remove the extra files from your exported config containing `upgrade_upgrade_ and then import config.
Example:
drush cex
rm *upgrade_upgrade_*.yml
drush cim
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | migrate_upgrade-n3039544-30.patch | 3.17 KB | alejo d |
| #30 | migrate_upgrade-n3039544-29.patch | 988 bytes | alejo d |
| #28 | migrate_upgrade-n3039544-28.patch | 4 KB | damienmckenna |
| #28 | migrate_upgrade-n3039544-28.interdiff.txt | 737 bytes | damienmckenna |
| #27 | migrate_upgrade-n3039544-27.patch | 3.7 KB | damienmckenna |
Comments
Comment #2
juampynr commentedHere is a patch that fixes it.
Comment #3
juampynr commentedComment #4
heddnWould be awful nice to have a test added?
Comment #5
heddnalso:
Comment #6
heddnComment #7
juampynr commentedComment #8
aiphesMaybe relative to my issue with D6 : https://www.drupal.org/project/migrate_upgrade/issues/3047436
Comment #9
juampynr commentedHere is an updated patch that includes a test. I am also including a test-only patch.
Comment #11
heddnJust a small nit:
I think there's an assertCount method in phpunit?
Comment #12
heddnAlso, looks like phpcs found something:
Comment #13
juampynr commentedThanks for the feedback @heddn!
I fixed the coding standards issue. As for the assertCount(), I decided to leave it as it is as it seemed more clear to me. Here is what the patch does:
And here is how it should be written using assertCount:
Comment #15
juampynr commentedTriggered a re-test since I cannot reproduce the PHP warning.
Comment #17
juampynr commentedCan anyone reproduce the warning? I cannot, not even using run_tests.sh.
Comment #18
juampynr commentedComment #19
damienmckennaThe question is, what would cause $plugin['plugin'] to be empty? I was able to reproduce it locally and used print_r() to find out what the plugin was:
Comment #20
damienmckennaFWIW I tested with Drush 10, maybe there's a bug that doesn't show in Drush 9?
Comment #21
heddnIt isn't very clear here what is needed?
Comment #22
heddnThis seems like a better solution?
Comment #23
sinasalek commentedApplied it against the latest dev and worked. thank you
Comment #24
solideogloria commentedIs there a way to remove existing migrations after duplicates with extra prefixes have already been created?
Comment #25
steinmb commented@solideogloria Added work around to issue summary.
Comment #26
damienmckennaRerolled.
Comment #27
damienmckennaThis is the error:
Let's see if this covers it.
Comment #28
damienmckennaOne more try..
Comment #29
damienmckennaIs Composer being executed against the project before the patch is applied?
Comment #30
alejo dLet's see if this covers it.
Comment #31
alejo dAdded tests.
Comment #32
heddnThis was fixed in https://gitlab.com/drupalspoons/migrate_upgrade/-/merge_requests/2.