Allow OR/AND groups of tags in drush --tag argument

Created on 9 January 2024, 12 months ago
Updated 31 May 2024, 7 months ago

Problem/Motivation

An enhancement for the --tag drush argument where you could AND multiple tags, something like:

Desired: drush mim --tag=node+translation

"only import migrations tagged with BOTH node AND translation tags" VS:

Current: drush mim --tag=node,translation

"import ANY migrations tagged with EITHER node OR translation tags"

Current workaround is going through the tedious work of adding "node_translation" to all the various migrations, and then "paragraph_translation" to all the various paragraph translations, and so on.

Proposed resolution

Use an easy to understand syntax to indicate which migration tags should be AND-ed together, vs the default behavior of OR. May also require BC to the default OR behavior, and the potential of introducing some kid of [grouping] mechanic/syntax.

Link to conversation on Slack: https://drupal.slack.com/archives/C226VLXBP/p1704817597199859

Remaining tasks

  1. Determine what keyword model/syntax would work best
  2. BC considerations + testing

User interface changes

API changes

Data model changes

✨ Feature request
Status

Closed: works as designed

Version

6.0

Component

Drush commands

Created by

πŸ‡ΊπŸ‡ΈUnited States amaisano Boston

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @amaisano
  • πŸ‡ΊπŸ‡ΈUnited States amaisano Boston
  • πŸ‡ΊπŸ‡ΈUnited States amaisano Boston
  • πŸ‡ΊπŸ‡ΈUnited States amaisano Boston
  • πŸ‡ΊπŸ‡ΈUnited States amaisano Boston

    Secondary thought - I just had a use case of running everything EXCEPT. So some kind of negation would be a cool bonus feature:

    drush mim --all --tag=!translation #import everything except migrations tagged "translation"

  • πŸ‡³πŸ‡ΏNew Zealand xurizaemon Ōtepoti, Aotearoa 🏝

    As suggested in the Slack thread, I think it's worth picking a syntax which produces a decent UX on the commandline, and ideally one which is already established (rather than coming up with our own).

    From Migrate's side, we should consider that selecting characters like ! ~ & + , will potentially modify how some existing tags in existing migrations behave.

    Considering use from CLI, we have to consider the UX as well when we use characters, which will probably mean --tag="foo&&bar" to avoid behaviour of characters handled specially by the shell (! & etc).

    Thinking about the grouping syntax suggestion in Slack, I think CLI syntax has to be clear and concise as well. (I suspect grouping might be more complicated than this feature needs?)

    The proposal reminds me of Behat's Gherkin filter syntax, which does most of what you've proposed here - it has OR, AND and NOT, but does not have grouping.

    Examples (see https://docs.behat.org/en/v2.5/guides/6.cli.html#gherkin-filters to unpack):

     --tags 'orm,database' # Tests tagged orm or database
     --tags 'orm&&fixtures' # Tests with both orm and fixtures tags
     --tags '~javascript' # All tests except javascript
     --tags 'orm&&fixtures&&~javascript' # Tests with both orm and fixtures, except if they have javascript 
    

    I'm sure there are other syntaxes which are similar and might fit as well - my suggestion is that if possible we select an existing syntax that'll be familiar or accessible to the community, rather than rolling our own. Are there any Drush commands which already have something similar?

  • Status changed to Closed: works as designed 7 months ago
  • heddn Nicaragua

    The current approach is probably fine. If someone needs to do this, they can type the different tags manually.

Production build 0.71.5 2024