-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow resetting the status of multiple migrations #5287
Open
DieterHolvoet
wants to merge
2
commits into
drush-ops:11.x
Choose a base branch
from
DieterHolvoet:feature/migrate-reset-multiple
base: 11.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -570,29 +570,50 @@ public function stop(string $migrationId): void | |
* | ||
* @command migrate:reset-status | ||
* | ||
* @param string $migrationId | ||
* The ID of migration to reset. | ||
* @param string|null $migrationIds | ||
* Comma-separated list of migration IDs. | ||
* | ||
* @aliases mrs,migrate-reset-status | ||
* | ||
* @topics docs:migrate | ||
* | ||
* @option all Process all migrations. | ||
* @option tag A comma-separated list of migration tags to rollback | ||
* | ||
* @usage migrate:reset-status --all | ||
* Reset the status of all migrations | ||
* @usage migrate:reset-status --tag=user,main_content | ||
* Reset the status of all migrations tagged with <info>user</info> and <info>main_content</info> tags | ||
* @usage migrate:reset-status classification,article | ||
* Reset the status of the <info>classification</info> and <info>article</info> migrations | ||
* | ||
* @validate-module-enabled migrate | ||
* @validate-migration-id | ||
* @version 10.4 | ||
* | ||
* @throws PluginException | ||
*/ | ||
public function resetStatus(string $migrationId): void | ||
public function resetStatus(?string $migrationIds = null, array $options = ['all' => false, 'tag' => self::REQ]): void | ||
{ | ||
/** @var MigrationInterface $migration */ | ||
$migration = $this->migrationPluginManager->createInstance($migrationId); | ||
$status = $migration->getStatus(); | ||
if ($status == MigrationInterface::STATUS_IDLE) { | ||
$this->logger()->warning(dt('Migration @id is already Idle', ['@id' => $migrationId])); | ||
} else { | ||
$migration->setStatus(MigrationInterface::STATUS_IDLE); | ||
$this->logger()->success(dt('Migration @id reset to Idle', ['@id' => $migrationId])); | ||
$tags = $options['tag']; | ||
$all = $options['all']; | ||
|
||
if (!$all && !$migrationIds && !$tags) { | ||
throw new \Exception(dt('You must specify --all, --tag, or one or more migration names separated by commas')); | ||
} | ||
|
||
if (!$list = $this->getMigrationList($migrationIds, $options['tag'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've already assign |
||
$this->logger()->error(dt('No migrations found.')); | ||
} | ||
|
||
foreach ($list as $migrations) { | ||
foreach ($migrations as $migrationId => $migration) { | ||
/** @var MigrationInterface $migration */ | ||
$status = $migration->getStatus(); | ||
if ($status !== MigrationInterface::STATUS_IDLE) { | ||
$migration->setStatus(MigrationInterface::STATUS_IDLE); | ||
$this->logger()->success(dt('Migration @id reset to Idle', ['@id' => $migrationId])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
} | ||
} | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if some are using:
--all
with--tag
and some migration names?--all
with--tag
?--all
with a list of migrations?Maybe we should remove
--all
and NO MIGRATIONS == ALL? Then:--tag
: All migrations filtered by provided tags--tag
: should return error (or filter the list on tags?)