Skip to content

Commit

Permalink
HookUtils: Load also the last failed state from DB if any
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Sep 4, 2023
1 parent 9a88649 commit 4ead693
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/Icinga/Application/Hook/Common/HookUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use ipl\Orm\Query;
use ipl\Sql\Adapter\Pgsql;
use ipl\Sql\Connection;
use ipl\Stdlib\Filter;
use PDO;

trait HookUtils
Expand Down Expand Up @@ -146,6 +147,15 @@ protected function loadLastState(string $version): ?string
$session = Session::getSession()->getNamespace('migrations');
$states = $session->get($this->getModuleName(), []);
if (! isset($states[$version])) {
$schema = $this->schemaQuery($version);
$schema->setFilter(Filter::all(Filter::equal('success', 'n')));
if (static::getColumnType($this->getDb(), $schema->getModel()->getTableName(), 'reason')) {
$schema = $schema->first();
if ($schema) {
return $schema->reason;
}
}

return null;
}

Expand Down

0 comments on commit 4ead693

Please sign in to comment.