How can I regenerate the entities generated by Drush? I get an error regarding the migration group existing. I would like to be able to just simply overwrite these.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michaelmallett created an issue. See original summary.

mathieuhelie’s picture

Status: Active » Needs review
FileSize
1.83 KB

I wanted to do exactly that for a dev workflow on migration templates.

The attached patch should update existing entities instead of triggering an exception.

mathieuhelie’s picture

Title: How to regenerate config entities? » Regenerate config entities when using --config-only multiple times.
mikeryan’s picture

Version: 8.x-3.0-rc1 » 8.x-3.x-dev
Status: Needs review » Needs work
  1. +++ b/src/MigrateUpgradeDrushRunner.php
    @@ -182,8 +182,19 @@ class MigrateUpgradeDrushRunner {
    +    } else {
    
    @@ -195,7 +206,15 @@ class MigrateUpgradeDrushRunner {
    +      } else {
    

    Coding standards: else should be on a new line.

  2. +++ b/src/MigrateUpgradeDrushRunner.php
    @@ -182,8 +182,19 @@ class MigrateUpgradeDrushRunner {
    +      foreach ($group as $key => $value) {
    +        if ($key != 'id') {
    +          $group_entity->set($key, $value);
    +        }
    +      }
    
    @@ -195,7 +206,15 @@ class MigrateUpgradeDrushRunner {
    +        foreach ($entity_array as $key => $value) {
    +          $migration_entity->set($key, $value);
    +        }
    

    Is there a better way to replace an entity's values? In particular, it looks like if there's something in the existing entity which is not in the new array of values, it will not be removed.

Thanks!

mathieuhelie’s picture

Category: Support request » Feature request
Status: Needs work » Needs review
FileSize
2.96 KB

Rerolled the patch with reviewer comments.

heddn’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +Needs tests

Patch no longer applies. It would also be a good thing to add a simple kernel test that tries to re-run the configure and reproduce this issue. We need more tests in this space.

rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.13 KB

rerolled

heddn’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs a re-roll again.

rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.22 KB
heddn’s picture

FileSize
4.84 KB
5.78 KB

A little code cleanup.

  • heddn committed dba6379 on 8.x-3.x
    Issue #2850309 by mathieuhelie, rpayanm, heddn: Regenerate config...
heddn’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Thanks for all your contributions.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

timwood’s picture

Hello, Sorry to post this on a closed issue, but it seems related.

For whatever reason, I cannot get a repeat drush migrate-upgrade --configure-only command to match the existing migration prefix. My existing yml config files are for example migrate_plus.migration.upgrade_d7_block.yml and migrate_plus.migration.upgrade_system_site.yml. I presume from these filenames the migration prefix is upgrade_, but when I specify that prefix in my subsequent command, including my legacy db key drush migrate-upgrade --legacy-db-key=migrate --configure-only --migration-prefix=upgrade_ I get new config names like so: migrate_plus.migration.upgrade_upgrade_d7_block.yml and migrate_plus.migration.upgrade_upgrade_system_site.yml (notice the duplicate upgrade_). If I leave off the --migration-prefix option or set it to nothing I get new config names like this (no prefix): migrate_plus.migration.d7_block.yml and migrate_plus.migration.system_site.yml.

Any idea how to get a repeat migrate-upgrade --configure-only command to match my existing migration configuration names?

timwood’s picture

The only way I can get this to work is to delete the existing migration group in the Drupal config at https://example.com/admin/structure/migrate and re-run the drush migrate-upgrade --legacy-db-key=migrate --configure-only. Then run drush cex and review the git diff for the changes I want to keep.

juampynr’s picture

@timwood I also faced the issue that you reported at #14 and created #3039544: migrate-upgrade keeps prefixing upgrade_ on subsequent runs to provide a fix.

juampynr’s picture