From 8c28e4e96cbced5360ecf9e89b15e12b69a0420d Mon Sep 17 00:00:00 2001 From: David Badura Date: Mon, 7 Aug 2023 22:59:24 +0200 Subject: [PATCH] add rebuild command & error message in projectionist status command --- .../Command/ProjectionistRebuildCommand.php | 45 +++++++++++++++++++ .../Command/ProjectionistStatusCommand.php | 2 + 2 files changed, 47 insertions(+) create mode 100644 src/Console/Command/ProjectionistRebuildCommand.php diff --git a/src/Console/Command/ProjectionistRebuildCommand.php b/src/Console/Command/ProjectionistRebuildCommand.php new file mode 100644 index 000000000..28fd112b4 --- /dev/null +++ b/src/Console/Command/ProjectionistRebuildCommand.php @@ -0,0 +1,45 @@ +projectionCriteria($input); + + if (!$io->confirm('do you want to rebuild all projections?', false)) { + return 1; + } + + $this->eventDispatcher->addSubscriber(new ThrowErrorListener()); + + $this->projectionist->remove($criteria); + $this->projectionist->boot($criteria); + + return 0; + } +} diff --git a/src/Console/Command/ProjectionistStatusCommand.php b/src/Console/Command/ProjectionistStatusCommand.php index bd8e584ae..73117e838 100644 --- a/src/Console/Command/ProjectionistStatusCommand.php +++ b/src/Console/Command/ProjectionistStatusCommand.php @@ -29,6 +29,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'version', 'position', 'status', + 'error message', ], array_map( static fn (Projection $projection) => [ @@ -36,6 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $projection->id()->version(), $projection->position(), $projection->status()->value, + $projection->errorMessage(), ], [...$projections], ),