Add a farm_migrate:rollback Drush command that rolls back all farmOS migrations.
This commit is contained in:
parent
a24c3ff221
commit
1652c4746f
|
@ -75,6 +75,28 @@ known issues.
|
|||
|
||||
Please open bug reports in the farmOS issue queue if new issues are discovered.
|
||||
|
||||
## Rolling back migration
|
||||
|
||||
Migrations can be rolled back with the following command:
|
||||
|
||||
drush farm_migrate:rollback
|
||||
|
||||
Alternatively, migration groups can be rolled back individually. This should be
|
||||
done in the following order (reverse of the order of import):
|
||||
|
||||
drush migrate:import --group=farm_migrate_plan
|
||||
drush migrate:import --group=farm_migrate_log
|
||||
drush migrate:import --group=farm_migrate_quantity
|
||||
drush migrate:import --group=farm_migrate_sensor_data
|
||||
drush migrate:import --group=farm_migrate_asset_parent
|
||||
drush migrate:import --group=farm_migrate_area
|
||||
drush migrate:import --group=farm_migrate_asset
|
||||
drush migrate:import --group=farm_migrate_taxonomy
|
||||
drush migrate:import --group=farm_migrate_file
|
||||
drush migrate:import --group=farm_migrate_user
|
||||
drush migrate:import --group=farm_migrate_role
|
||||
drush migrate:import --group=farm_migrate_config
|
||||
|
||||
## Migrating files
|
||||
|
||||
farmOS allows files to be uploaded/attached to records. In order to migrate
|
||||
|
|
|
@ -22,6 +22,17 @@ class FarmMigrateCommands extends MigrateToolsCommands {
|
|||
$this->executeFarmMigrations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback a 1.x data migration.
|
||||
*
|
||||
* @command farm_migrate:rollback
|
||||
*
|
||||
* @usage farm_migrate:rollback
|
||||
*/
|
||||
public function farmRollback() {
|
||||
$this->executeFarmRollback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the farmOS migration groups in the order they should be executed.
|
||||
*
|
||||
|
@ -61,4 +72,21 @@ class FarmMigrateCommands extends MigrateToolsCommands {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback all farmOS migrations.
|
||||
*
|
||||
* @throws \Exception
|
||||
* If some rollbacks failed during execution.
|
||||
*/
|
||||
protected function executeFarmRollback() {
|
||||
$groups = $this->farmMigrationGroups();
|
||||
$groups = array_reverse($groups);
|
||||
foreach ($groups as $group) {
|
||||
$options = [
|
||||
'group' => $group,
|
||||
];
|
||||
$this->rollback('', $options);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue