Chris@0: 'Perform one or more upgrade processes.', Chris@0: 'options' => [ Chris@0: 'legacy-db-url' => 'A Drupal 6 style database URL. Required if you do not set legacy-db-key.', Chris@0: 'legacy-db-key' => 'A database connection key from settings.php. Use as an alternative to legacy-db-url', Chris@0: 'legacy-db-prefix' => 'Prefix of the legacy Drupal installation.', Chris@0: 'legacy-root' => 'Site address or root of the legacy Drupal installation', Chris@0: 'configure-only' => 'Set up the appropriate upgrade processes but do not perform them', Chris@0: 'migration-prefix' => 'With configure-only, a prefix to apply to generated migration ids. Defaults to \'upgrade_\'', Chris@0: ], Chris@0: 'examples' => [ Chris@0: 'migrate-upgrade --legacy-db-url=\'mysql://root:pass@127.0.0.1/d6\'' => 'Upgrade a Drupal 6 database to Drupal 8', Chris@0: 'migrate-upgrade --legacy-db-key=\'drupal_7\'' => 'Upgrade Drupal 7 database where the connection to Drupal 7 has already been created in settings.php ($databases[\'drupal_7\'])', Chris@0: 'migrate-upgrade --legacy-db-url=\'mysql://root:pass@127.0.0.1/d7\' --configure-only --migration-prefix=d7_custom_' => 'Generate migrations for a custom migration from Drupal 7 to Drupal 8', Chris@0: ], Chris@0: 'drupal dependencies' => ['migrate_upgrade'], Chris@0: ]; Chris@0: $items['migrate-upgrade-rollback'] = [ Chris@0: 'description' => 'Rolls back and removes upgrade migrations.', Chris@0: 'examples' => [ Chris@0: 'migrate-upgrade-rollback' => 'Rolls back a previously-run upgrade', Chris@0: ], Chris@0: 'drupal dependencies' => ['migrate_upgrade'], Chris@0: ]; Chris@0: Chris@0: return $items; Chris@0: } Chris@0: Chris@0: /** Chris@4: * Execute the upgrade command, configuring the necessary migrations. Chris@4: * Chris@4: * Optionally perform the imports. Chris@0: */ Chris@0: function drush_migrate_upgrade() { Chris@0: $runner = new MigrateUpgradeDrushRunner(); Chris@0: Chris@0: try { Chris@0: $runner->configure(); Chris@0: if (drush_get_option('configure-only')) { Chris@0: $runner->export(); Chris@0: } Chris@0: else { Chris@0: $runner->import(); Chris@0: \Drupal::state()->set('migrate_drupal_ui.performed', \Drupal::time()->getRequestTime()); Chris@0: } Chris@0: // Remove the global database state. Chris@0: \Drupal::state()->delete('migrate.fallback_state_key'); Chris@0: } Chris@0: catch (\Exception $e) { Chris@0: drush_log($e->getMessage(), 'error'); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@4: * Rolls back any upgrade migrations that are present. Chris@0: */ Chris@0: function drush_migrate_upgrade_rollback() { Chris@0: if ($date_performed = \Drupal::state()->get('migrate_drupal_ui.performed')) { Chris@0: if (drush_confirm(dt('All migrations tagged as \'Drupal\' will be rolled back. Are you sure?'))) { Chris@0: $runner = new MigrateUpgradeDrushRunner(); Chris@0: Chris@0: try { Chris@0: drush_log(dt('Rolling back the upgrades performed @date', Chris@0: ['@date' => \Drupal::service('date.formatter')->format($date_performed)])); Chris@0: $runner->rollback(); Chris@0: \Drupal::state()->delete('migrate_drupal_ui.performed'); Chris@0: drush_log(dt('Rolled back upgrades')); Chris@0: } Chris@0: catch (\Exception $e) { Chris@0: drush_log($e->getMessage(), 'error'); Chris@0: } Chris@0: } Chris@0: else { Chris@0: drush_user_abort(); Chris@0: } Chris@0: } Chris@0: else { Chris@0: drush_log(dt('No upgrade operation has been performed.'), 'warning'); Chris@0: } Chris@0: }