I have a list of migrations which are split by groups. And some of the migrations have cross-group dependencies, i.e.:
groupA
migration_A depends on migration_B
groupB
migration_B
In this case drush_migrate_tools_migration_list() function will break migration dependencies because it arranges them by groups:
...
// Sort the matched migrations by group.
if (!empty($matched_migrations)) {
foreach ($matched_migrations as $id => $migration) {
$configured_group_id = empty($migration->get('migration_group')) ? 'default' : $migration->get('migration_group');
$migrations[$configured_group_id][$id] = $migration;
}
}
return isset($migrations) ? $migrations : [];
@see: http://cgit.drupalcode.org/migrate_tools/tree/migrate_tools.drush.inc#n490
I personally don't see a great value in running migrations by groups, it's more like an aesthetic thing. I'll try to provide a patch.
Comments
Comment #2
OnkelTem commentedComment #3
OnkelTem commentedComment #4
heddnI'm not sure how BC we want this to be. If we wanted full BC, we'd add a new argument to ignore by grouping and default it to false. But maybe it isn't that important and we just remove that functionality?
Comment #5
Grayside commentedThis might explain why migration dependencies were mysteriously failing across a couple dozen migrations, split across a half-dozen groups.
Since the current behavior is a consistency bug in which dependency is not uniformly enforced, it seems like b/c is unnecessary. There's already --force to ignore dependency if that's needed.
Comment #6
OnkelTem commentedAfter few weeks of testing I can say it works fine for our tasks.
@Grayside
> There's already --force to ignore dependency if that's needed.
Sure, but from my experience I can say that ignoring any dependency is a certain way to miss an error. I've found only one use case when we might need this: it's when two or more migrations depend on one "with a dynamic nature" like XML feed for example, i.e. one which can change during the migration process, making it impossible to finish it to the end.
Comment #7
Grayside commentedOnkelTem I'm arguing that backwards compatibility to the current broken behavior is not needed because --force exists.
Comment #8
OnkelTem commentedThe #3 patch is not complete, as it's missing the rollback part.
Updating the patch.
Comment #9
mikeryanCoding standards - two-space indentation, 80-char line.
Following line appears to be accidentally appended here.
This needs to be indented.
This violates the documented return, which is an array of array of migrations (and required the import and rollback commands to change to accommodate it). How about
and then the changes (other than passing FALSE where necessary) are isolated here?
Thanks!
Comment #10
heddnComment #11
manarth commentedUpdated patch against the
6.0.xbranch.migrate:statuscommand.--limitproperty is now treated as a total items to migrate, rather than a limit-per-migration. E.g.drush migrate:import --all --limit=200will process the migration definitions in dependency order, migrating up to a combined total of 200 items.Comment #12
manarth commentedPatch updated to also perform migration when
--limitis not specified.Comment #14
rakesh.gectcrRe-rolled
Comment #15
rakesh.gectcrComment #17
manarth commentedRerolled patch from 12 (patch is now against release 6.0.1).
Comment #18
manarth commentedCorrect the filepath from patch in 17 to include the full module path (not just the bare file).
Comment #20
heddnLooks like there are still some failing tests. Back to NW.