function drush_migrate_tools_migrate_rollback in Migrate Tools 8.3
Same name and namespace in other branches
- 8 migrate_tools.drush.inc \drush_migrate_tools_migrate_rollback()
- 8.2 migrate_tools.drush.inc \drush_migrate_tools_migrate_rollback()
- 8.4 migrate_tools.drush.inc \drush_migrate_tools_migrate_rollback()
Parameters
string $migration_names:
File
- ./
migrate_tools.drush.inc, line 290 - Command-line tools to aid performing and developing migrations.
Code
function drush_migrate_tools_migrate_rollback($migration_names = '') {
$group_names = drush_get_option('group');
$tag_names = drush_get_option('tag');
$all = drush_get_option('all');
$options = [];
if (!$all && !$group_names && !$migration_names && !$tag_names) {
drush_set_error('MIGRATE_ERROR', dt('You must specify --all, --group, --tag, or one or more migration names separated by commas'));
return;
}
if (drush_get_option('feedback')) {
$options['feedback'] = drush_get_option('feedback');
}
$log = new DrushLogMigrateMessage();
$migrations = drush_migrate_tools_migration_list($migration_names);
if (empty($migrations)) {
drush_log(dt('No migrations found.'), 'error');
}
// Take it one group at a time, rolling back the migrations within each group.
foreach ($migrations as $group_id => $migration_list) {
// Roll back in reverse order.
$migration_list = array_reverse($migration_list);
foreach ($migration_list as $migration_id => $migration) {
$executable = new MigrateExecutable($migration, $log, $options);
// drush_op() provides --simulate support.
drush_op(array(
$executable,
'rollback',
));
}
}
}