You are here

public function MigrateUpgradeCommands::upgradeRollback in Migrate Upgrade 8.3

Rolls back and removes upgrade migrations.

@command migrate:upgrade-rollback @usage drush migrate-upgrade-rollback Rolls back a previously-run upgrade. It will not rollback migrations exported as migrate_plus config entities. @validate-module-enabled migrate_upgrade @aliases migrate-upgrade-rollback, mupr

Throws

\Drush\Exceptions\UserAbortException If user chose to not perform the rollback.

File

src/Commands/MigrateUpgradeCommands.php, line 221

Class

MigrateUpgradeCommands
Migrate Upgrade drush commands.

Namespace

Drupal\migrate_upgrade\Commands

Code

public function upgradeRollback() {
  if ($date_performed = $this->state
    ->get('migrate_drupal_ui.performed')) {
    if ($this
      ->io()
      ->confirm(dt('All migrations will be rolled back. Are you sure?'))) {
      $runner = new MigrateUpgradeDrushRunner($this->logger);
      $this
        ->logger()
        ->notice(dt('Rolling back the upgrades performed @date', [
        '@date' => \Drupal::service('date.formatter')
          ->format($date_performed),
      ]));
      $runner
        ->rollback();
      $this->state
        ->delete('migrate_drupal_ui.performed');
      $this
        ->logger()
        ->notice(dt('Rolled back upgrades'));
    }
    else {
      throw new UserAbortException();
    }
  }
  else {
    $this
      ->logger()
      ->warning(dt('No upgrade operation has been performed.'));
  }
}