Problem/Motivation

In #2470882: Implement running migration processes through the UI, we decided it would be nice to have a batch feature to select multiple migrations and execute them.

Proposed resolution

Remaining tasks

  • Do it.
  • Test it.
  • Reap profits.

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#46 migrate_tools-ui-bulk-2924296-46.patch22.59 KBlarvymortera
#44 migrate_tools-ui-bulk-2924296-44.patch30.17 KBfskreuz
#42 migrate_tools-ui-bulk-2924296-42.patch31.18 KBsorlov
#39 interdiff-2924296-37-39.txt3.53 KBsorlov
#39 migrate_tools-ui-bulk-2924296-39.patch30.88 KBsorlov
#37 interdiff-2924296-36-37.txt673 bytesYurkinPark
#37 2924296-37.patch30.6 KBYurkinPark
#36 interdiff-2924296-35-36.txt4.38 KBYurkinPark
#36 2924296-36.patch30.53 KBYurkinPark
#35 interdiff-2924296-33-35.txt878 bytesYurkinPark
#35 2924296-35.patch25.74 KBYurkinPark
#33 interidff-2924296-30-33.txt408 bytesYurkinPark
#33 2924296-33.patch24.72 KBYurkinPark
#30 2924296-30.patch24.42 KBravi.shankar
#23 migrate_tools_ui.png73.11 KBbserem
#22 interdiff_21-22.txt6.72 KBheddn
#22 2924296-22.patch24.68 KBheddn
#21 migrate_tools-migrate-group-batch-ui-29244296-21.patch23.64 KBkriboogh
#19 2924296-19.patch23.4 KBkriboogh
#18 2924296-18-batch_vbo.patch27.56 KBkriboogh
#17 2924296-17.patch22.67 KBkriboogh
#15 2924296-15.patch22.46 KBrpayanm
#12 migrate_tools-migrate-group-batch-ui-29244296-12.patch22.79 KBsokru
#9 migrate_tools-migrate-group-batch-ui-29244296-9.patch23.12 KBkriboogh
#8 migrate_tools-migrate-group-batch-ui-29244296-8.patch8.16 KBkriboogh
#7 migrate_tools-ui-bulk-2924296-7.patch18.01 KBkriboogh
#5 migrate_tools-ui-bulk-2924296-addmissingfile-4.patch24.1 KBmschudders
#4 migrate_tools-ui-bulk-2924296-addmissingfile-4.patch24.1 KBmschudders
#2 migrate_tools-ui-bulk-2924296-2.patch23.59 KBkriboogh
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

heddn created an issue. See original summary.

kriboogh’s picture

StatusFileSize
new23.59 KB

Added bulk execution.

heddn’s picture

Issue tags: +Needs tests

Needs work also because needs tests.

mschudders’s picture

Correct patch for missing "MigrateBatchMessage" class.

mschudders’s picture

Correct patch #1

mschudders’s picture

kriboogh’s picture

StatusFileSize
new18.01 KB

Updated patch for latest 4.x

kriboogh’s picture

StatusFileSize
new8.16 KB

Patch was not deploying, corrected.

kriboogh’s picture

StatusFileSize
new23.12 KB

Patch updated

trebormc’s picture

#9 Works fine

Thanks.

I love the Drupal community just for things like this

heddn’s picture

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

Could use a re-roll. And it isn't passing phpcs.

sokru’s picture

Reroll, some coding standards and few comments below:
in src/Controller/MigrationListBuilder.php #72
LoggerChannelInterface has removed from 8.x-4-x, replaced with LoggerInterface.

in src/Controller/MigrationListBuilder.php #309
added missing documentation.

in src/MigrateBatchExecutable.php #179
currently in latest 8.x-4.x:
`$operations = array_merge($operations, $this->batchOperations($required_migrations, $operation, [`
after the patch:
`$operations += static::batchOperations($required_migrations, $operation, [`

rpayanm’s picture

Status: Needs work » Needs review
heddn’s picture

Status: Needs review » Needs work

There's some code standard failures (see https://www.drupal.org/pift-ci-job/1391870) and we should have some tests.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new22.46 KB
ajits’s picture

Issue tags: -Needs reroll
kriboogh’s picture

StatusFileSize
new22.67 KB

Re-roll against 8x4.3

kriboogh’s picture

StatusFileSize
new27.56 KB

MigrateBatchMessage went missing in the last re-roll.

kriboogh’s picture

StatusFileSize
new23.4 KB

Fixed patch (wasn't applying correctly

heddn’s picture

Status: Needs review » Needs work

Still doesn't apply cleanly.

kriboogh’s picture

StatusFileSize
new23.64 KB

Maybe now...

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new24.68 KB
new6.72 KB

Still needs tests, but at least here are the PHPCS fixes.

bserem’s picture

Status: Needs review » Needs work
StatusFileSize
new73.11 KB

Patch in #22 applies. There are some things that I'd like to express that might or might not be relevant to the task at hand.

tl;dr: It works. See comment-24.

On this custom migration module:

$ tree
.
├── faq_csv_migrate.info.yml
├── migrations
│   └── users.yml
└── README.md

I get this drush output, after drush mim --group users:

$ drush ms
 ------------------- ------------------ -------- ------- ---------- ------------- --------------------- 
  Group               Migration ID       Status   Total   Imported   Unprocessed   Last Imported        
 ------------------- ------------------ -------- ------- ---------- ------------- --------------------- 
  Users (users)       users              Idle     20      20         0             2019-11-01 23:36:35  

 ------------------- ------------------ -------- ------- ---------- ------------- --------------------- 

On the UI I see the execute all button, and it actually works and imports stuff. But there is no option to select which migration to run nor does it identify migration groups:
migrate tools ui

The YML source of the migration file is:

# Sample data: https://mockaroo.com/01238430
# id,uid,mail,username,pass,status,role,created,access,changed
id: users
label: 'Import Users'
migration_tags:
  - users
migration_group: users
source:
  # https://www.drupal.org/node/2574707
  plugin: csv
  path: 'public://migrations/users.csv'
  delimiter: ','
  enclosure: '"'
  header_row_count: 1
  ids:
    - id
process:
  #uid: uid
  name:
    plugin: skip_on_empty
    method: row
    source: username
    message: 'Username is missing.'
  mail: mail
  init: mail
  pass: pass
  status: status
  roles: role
  changed: changed
  created: created
  access: access
destination:
  plugin: 'entity:user'
migration_dependencies: null

I am gonna put this back to needs work until further clarification of what is to be expected on the UI.
I would expect to see a list of migrations and (maybe) some checkboxes on which to execute.
Feel free to bump it back to review if I missed the point here.

All in all, it works nicely! Nice work.

bserem’s picture

Status: Needs work » Needs review

Hmmm... it turns out I am facing a different UI issue here. The UI will not pick migrations that do not go into the config system.
So, the migrations/users.yml folder structure works fine with migrate (and updates with a plain drush cr) but it will not list migrations to the migrate_tools UI.

For migrations to be displayed in the UI they must go into config/install/migrate_plus.migration.users.yml

Bumping it back to "needs review" myself.

heddn’s picture

Status: Needs review » Needs work

I'm looking to roll a 4.5 migrate tools release in the next few days. This would be nice to see land with it, but if it doesn't, that's fine too. I'm not sure how much is left to do here, as there are still test failures.

bserem’s picture

I'll test this tomorrow, I just changed all my migrations from "migration" to "configuration" so as to test properly.

bserem’s picture

UI wise the patch works as long as migrations come from config like described above.

The execute all button works when importing but you can't rollback with it.

heddn’s picture

Still seems to need work because tests are failing.

heddn’s picture

Issue tags: +Needs reroll

And seems to need a re-roll.

ravi.shankar’s picture

StatusFileSize
new24.42 KB

Here I have added re-roll of patch #22.

bserem’s picture

Patch #30 works as expected (the button is there and it does the job) on Drupal 8.8

sorlov’s picture

Still cannot do rollback from UI with this patch

YurkinPark’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new24.72 KB
new408 bytes

will provide more batch tests

Status: Needs review » Needs work

The last submitted patch, 33: 2924296-33.patch, failed testing. View results

YurkinPark’s picture

Status: Needs work » Needs review
StatusFileSize
new25.74 KB
new878 bytes
YurkinPark’s picture

StatusFileSize
new30.53 KB
new4.38 KB

Added tests for current feature

YurkinPark’s picture

Issue tags: -Needs tests
StatusFileSize
new30.6 KB
new673 bytes

Minor comment changes

heddn’s picture

+++ b/src/MigrateBatchExecutable.php
@@ -84,23 +80,17 @@ class MigrateBatchExecutable extends MigrateExecutable {
+  public static function batchImport($migrations, $label, $options) {

+++ b/tests/modules/migrate_tools_test/src/Commands/MigrateToolsTestCommands.php
@@ -37,8 +36,7 @@ class MigrateToolsTestCommands extends DrushCommands {
+    MigrateBatchExecutable::batchImport([$fruit_migration], 'Fruit terms', []);

This is a BC break. Folks extend the executable in their own code. Making this modification will break them.

And there seems to be a lot of work on batch and batch rollback in here. Can we split those pieces off into their own dedicated issues?

sorlov’s picture

Made next changes:

  1. According to previous comment, I have reverted changes to batchImport() to keep it compartible and made batchMassImport() function.
  2. Updated batchOperations() to keep dependencies only for Import operation, but not Rollback
  3. Updated batchReset() to set Idle status
heddn’s picture

Status: Needs review » Needs work

This is a really hard to review issue in its current state. Are there smaller parts we can break up that are more closely scoped that will get us close to VBO support? Then a final form facing issue that just wires into the API?

Plus, NW for PHPCS.

sorlov’s picture

Status: Needs work » Needs review

I think, only part that can be separated - making batch rollback for MigrationExecuteForm

But actually, I don't see any difficulties with current patch.

We have only 3 main parts here:
1. Add ability to select migrations and run operations for them in MigrationListBuilder
2. Update MigrateBatchExecutable to run batch operations for multiple migrations
3. Update MigrationExecuteForm to use the same way as for MigrationListBuilder

sorlov’s picture

StatusFileSize
new31.18 KB

Reroll for patch from #39

tonytheferg’s picture

Slick feature, but I normally see 2-3 pages of migrations, and with the patch applied I only see the first page?

fskreuz’s picture

StatusFileSize
new30.17 KB

Rerolled patch #42 against 5.x

james.williams’s picture

larvymortera’s picture

Version: 8.x-4.x-dev » 6.0.x-dev
Issue tags: -Needs reroll
StatusFileSize
new22.59 KB

Rerolled patch #44 against 6.0.x

Status: Needs review » Needs work

The last submitted patch, 46: migrate_tools-ui-bulk-2924296-46.patch, failed testing. View results

aron novak made their first commit to this issue’s fork.

aron novak’s picture

Status: Needs work » Needs review

Let's see if tests do pass.

aron novak’s picture

Status: Needs review » Needs work
aron novak’s picture

Status: Needs work » Needs review

The patch was applied to latest dev as a MR, also I added test coverage.

heddn’s picture

Posted some feedback on the MR.

heddn’s picture

Version: 6.0.x-dev » 6.1.x-dev
Status: Needs review » Needs work