Skip to content

Commit

Permalink
Keep compatibility with Icinga DB mysql v6 & pgsql v4
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jan 13, 2025
1 parent ffd5126 commit 6de9b18
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion application/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function init()
Filter::equal('host.name', $hostName)
));

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$query->withColumns(['has_problematic_parent']);
}

Expand Down
9 changes: 9 additions & 0 deletions library/Icingadb/Common/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,13 @@ public static function getRedis(): IcingaRedis

return self::$redis;
}

public static function supportDependencies(): bool
{
if (self::getDb()->getAdapter() instanceof Pgsql) {
return self::getDbSchemaVersion() >= 5;
}

return self::getDbSchemaVersion() >= 7;
}
}
4 changes: 2 additions & 2 deletions library/Icingadb/Model/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getColumns()
'command_endpoint_id'
];

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$columns[] = 'affected_children';
}

Expand Down Expand Up @@ -166,7 +166,7 @@ public function getColumnDefinitions()
'command_endpoint_id' => t('Endpoint Id')
];

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$columns['affected_children'] = t('Affected Children');
}

Expand Down
2 changes: 1 addition & 1 deletion library/Icingadb/Model/HostState.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function getColumnDefinitions()
'next_update' => t('Host Next Update')
];

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$columns['affects_children'] = t('Host Affects Children');
}

Expand Down
6 changes: 3 additions & 3 deletions library/Icingadb/Model/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getColumns()
'command_endpoint_id'
];

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$columns[] = 'affected_children';
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public function getColumnDefinitions()
'command_endpoint_id' => t('Endpoint Id'),
];

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$columns['affected_children'] = t('Affected Children');
}

Expand Down Expand Up @@ -207,7 +207,7 @@ public function createBehaviors(Behaviors $behaviors)
'command_endpoint_id'
]));

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$behaviors->add(new HasProblematicParent());
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/Icingadb/Model/ServiceState.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getColumnDefinitions()
'next_update' => t('Service Next Update')
];

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$columns['affects_children'] = t('Service Affects Children');
}

Expand Down
2 changes: 1 addition & 1 deletion library/Icingadb/Model/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getColumns()
'next_update'
];

if (Backend::getDbSchemaVersion() >= 6) {
if (Backend::supportDependencies()) {
$columns[] = 'affects_children';
}

Expand Down
2 changes: 1 addition & 1 deletion library/Icingadb/Widget/Detail/ObjectDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ protected function fetchCustomVars()
*/
protected function createRootProblems(): ?array
{
if (Backend::getDbSchemaVersion() < 6) {
if (! Backend::supportDependencies()) {
if ($this->object->state->is_reachable) {
return null;
}
Expand Down

0 comments on commit 6de9b18

Please sign in to comment.