diff --git a/src/Commands/MigrateToolsCommands.php b/src/Commands/MigrateToolsCommands.php index 501c6ac..cd290b4 100644 --- a/src/Commands/MigrateToolsCommands.php +++ b/src/Commands/MigrateToolsCommands.php @@ -330,6 +330,7 @@ class MigrateToolsCommands extends DrushCommands { * @option group A comma-separated list of migration groups to rollback * @option tag ID of the migration tag to rollback * @option feedback Frequency of progress messages, in items processed + * @option missing-from-source Rollback only items missing from the source * * @usage migrate:rollback --all * Perform all migrations @@ -341,6 +342,9 @@ class MigrateToolsCommands extends DrushCommands { * Rollback all migrations in the beer group and with the user tag * @usage migrate:rollback beer_term,beer_node * Rollback imported terms and nodes + * @usage migrate-rollback --missing-from-source beer_term + * Rollback only the imported terms that are no longer available from the + * source * @validate-module-enabled migrate_tools * * @aliases mr, migrate-rollback @@ -355,6 +359,7 @@ class MigrateToolsCommands extends DrushCommands { 'group' => NULL, 'tag' => NULL, 'feedback' => NULL, + 'missing-from-source' => NULL, ] ) { $group_names = $options['group']; @@ -374,6 +379,8 @@ class MigrateToolsCommands extends DrushCommands { $this->logger()->error(dt('No migrations found.')); } + $operation = $options['missing-from-source'] ? 'rollbackMissingItems' : 'rollback'; + // Take it one group at a time, // rolling back the migrations within each group. foreach ($migrations as $group_id => $migration_list) { @@ -386,7 +393,7 @@ class MigrateToolsCommands extends DrushCommands { $additional_options ); // drush_op() provides --simulate support. - drush_op([$executable, 'rollback']); + drush_op([$executable, $operation]); } } }