Add the --idlist option to the drush migrate-rollback and mmsg command, where the option value is a comma-separated list of specific source IDs to rollback.

The other exciting thing, we now have tests of import and rollback in migrate_tools. Wohoo!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeryan created an issue. See original summary.

mikeryan’s picture

ckaotik’s picture

Status: Active » Needs review
FileSize
653 bytes
4.37 KB

I've written a patch for this, by overriding \Drupal\migrate_tools\MigrateExecutable::rollback based on \Drupal\migrate\MigrateExecutable::rollback.
It's actually a very straightforward change, just three lines when compared to Core - see the attached migrate_tools-rollback_core-diff.txt file.

heddn’s picture

Status: Needs review » Needs work

Drush 9 support is now in existence. Can we rewrite the features for drush 9 instead of drush 8?

brooke_heaton’s picture

Updated patch to work with Drush 9.

brooke_heaton’s picture

Status: Needs work » Needs review
heddn’s picture

Status: Needs review » Postponed

While reviewing this, I see we really should refactor that code in core as this is basically a copy/paste from there. And there are problems with it. Let's fix #2999478: Refactor MigrateExecutable::rollback() first, then come back and make this a lot easier and less brittle and commit this then.

heddn’s picture

I'm curious how this approach effects all the existing methods of filtering by id list? I wonder if this means we can remove all that existing logic? And if this will make things faster/easier to iterate?

heddn’s picture

FileSize
4.8 KB
941 bytes

Fixing phpcs.

heddn’s picture

Title: Implement --idlist option on migrate-rollback » Implement --idlist options on rollback and messages
Version: 8.x-2.x-dev » 8.x-4.x-dev
Issue summary: View changes
Related issues: +#2955034: No way to escape commas and colons in the idlist parameter for string ids that may contain them.
FileSize
4.18 KB
8.71 KB

I'm almost certain we can remove more code. And add more functionality. Let's extend this to messages as well. And maybe there is an easy way to escape the ids to answer #2955034: No way to escape commas and colons in the idlist parameter for string ids that may contain them.?

mikelutz’s picture

So removing the filter on the preparerow event breaks the --idlist option for imports? Can you implement a similar iterator filter on getSource() to filter the import and avoid filtering on the event?

heddn’s picture

FileSize
9.28 KB
15.24 KB

Much of this is completely untested, but the theory of it is that it would work...

And we'd have a consistent implementation of idlist filtering.

heddn’s picture

Issue summary: View changes
FileSize
6.27 KB
21.29 KB

Added some tests. They passed on local with the core patch... So that's exciting.

heddn’s picture

FileSize
21.21 KB

Entirely uninteresting phpcs fixes.

heddn’s picture

Status: Postponed » Needs review
Related issues: +#2999478: Refactor MigrateExecutable::rollback()

Core patch has landed. So let's do a test run now.

heddn’s picture

Status: Needs review » Needs work

We need to add some type of version check to the test if we want this to land before 8.7 goes stable. See the failure in #14.

heddn’s picture

Status: Needs work » Needs review
FileSize
7.44 KB
30.18 KB

Here, we now test and do things in a BC manner on 8.6. I also tested locally on 8.5 too.

  • heddn committed 7fdb973 on 8.x-4.x
    Issue #2798363 by heddn, ckaotik, brooke_heaton: Implement --idlist...
heddn’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

claudiu.cristea’s picture

What is the reason/use-case for adding the new --idlist-delimiter. Is there a scenario where ':' is not working?

heddn’s picture

If I recall, there were some systems that use UUIDs with the parts of the UUID delimited by that. ABCD:1234:ABCD:1234, or something like that.

claudiu.cristea’s picture

@heddn, if I’m reading correctly the code, that can be handled as --idlist=1:”id:containing:colons:1”,2:”2nd:id”

heddn’s picture

It was also a compound ID. Where there was a UUID and a langcode as part of the "ID".