Skip to content

Commit

Permalink
FEATURE: cr:prune --assume-yes flag to prune directly
Browse files Browse the repository at this point in the history
and improve code of `cr:prune` by using `resetAllProjections` instead of `replayAll` as this was done before only implicit.
  • Loading branch information
mhsdesign committed Jan 31, 2024
1 parent 216a3c8 commit 1865dd5
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,13 @@ public function resetAllCommand(string $contentRepository = 'default', bool $qui
* This will completely prune the data of the specified content repository.
*
* @param string $contentRepository name of the content repository where the data should be pruned from.
* @param bool $assumeYes prune the cr without confirmation. This cannot be reverted!
* @return void
*/
public function pruneCommand(string $contentRepository = 'default'): void
public function pruneCommand(string $contentRepository = 'default', bool $assumeYes = false): void
{
if (!$this->output->askConfirmation(sprintf("This will prune your content repository \"%s\". Are you sure to proceed? (y/n) ", $contentRepository), false)) {
if (!$assumeYes && !$this->output->askConfirmation(sprintf("This will prune your content repository \"%s\". Are you sure to proceed? (y/n) ", $contentRepository), false)) {
$this->outputLine('<comment>Abort.</comment>');
return;
}

Expand All @@ -183,14 +185,23 @@ public function pruneCommand(string $contentRepository = 'default'): void
$contentRepositoryId,
new ContentStreamPrunerFactory()
);
$contentStreamPruner->pruneAll();

$workspaceMaintenanceService = $this->contentRepositoryRegistry->buildService(
$contentRepositoryId,
new WorkspaceMaintenanceServiceFactory()
);

$projectionService = $this->contentRepositoryRegistry->buildService(
$contentRepositoryId,
$this->projectionServiceFactory
);

// reset the events table
$contentStreamPruner->pruneAll();
$workspaceMaintenanceService->pruneAll();
// reset the projections state
$projectionService->resetAllProjections();

$this->replayAllCommand($contentRepository);
$this->outputLine('<success>Done.</success>');
}
}

0 comments on commit 1865dd5

Please sign in to comment.