diff --git a/lib/db_ido/dbconnection.hpp b/lib/db_ido/dbconnection.hpp index f8221e9d2..5e061705f 100644 --- a/lib/db_ido/dbconnection.hpp +++ b/lib/db_ido/dbconnection.hpp @@ -12,8 +12,6 @@ #include #include -#define IDO_COMPAT_SCHEMA_VERSION "1.14.3" - namespace icinga { @@ -30,6 +28,7 @@ public: static void InitializeDbTimer(); virtual const char * GetLatestSchemaVersion() const noexcept = 0; + virtual const char * GetCompatSchemaVersion() const noexcept = 0; void SetConfigHash(const DbObject::Ptr& dbobj, const String& hash); void SetConfigHash(const DbType::Ptr& type, const DbReference& objid, const String& hash); diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index b30705479..678dffe28 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -26,6 +26,11 @@ const char * IdoMysqlConnection::GetLatestSchemaVersion() const noexcept return "1.14.3"; } +const char * IdoMysqlConnection::GetCompatSchemaVersion() const noexcept +{ + return "1.14.3"; +} + void IdoMysqlConnection::OnConfigLoaded() { ObjectImpl::OnConfigLoaded(); @@ -313,13 +318,13 @@ void IdoMysqlConnection::Reconnect() SetSchemaVersion(version); - if (Utility::CompareVersion(IDO_COMPAT_SCHEMA_VERSION, version) < 0) { + if (Utility::CompareVersion(GetCompatSchemaVersion(), version) < 0) { m_Mysql->close(&m_Connection); SetConnected(false); Log(LogCritical, "IdoMysqlConnection") << "Schema version '" << version << "' does not match the required version '" - << IDO_COMPAT_SCHEMA_VERSION << "' (or newer)! Please check the upgrade documentation at " + << GetCompatSchemaVersion() << "' (or newer)! Please check the upgrade documentation at " << "https://icinga.com/docs/icinga2/latest/doc/16-upgrading-icinga-2/#upgrading-mysql-db"; BOOST_THROW_EXCEPTION(std::runtime_error("Schema version mismatch.")); diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index 69f3d6134..9a63b819c 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -38,6 +38,7 @@ public: static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); const char * GetLatestSchemaVersion() const noexcept override; + const char * GetCompatSchemaVersion() const noexcept override; int GetPendingQueryCount() const override; diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 4ffa03399..ced62492a 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -28,6 +28,11 @@ const char * IdoPgsqlConnection::GetLatestSchemaVersion() const noexcept return "1.14.3"; } +const char * IdoPgsqlConnection::GetCompatSchemaVersion() const noexcept +{ + return "1.14.3"; +} + IdoPgsqlConnection::IdoPgsqlConnection() { m_QueryQueue.SetName("IdoPgsqlConnection, " + GetName()); @@ -280,13 +285,13 @@ void IdoPgsqlConnection::Reconnect() SetSchemaVersion(version); - if (Utility::CompareVersion(IDO_COMPAT_SCHEMA_VERSION, version) < 0) { + if (Utility::CompareVersion(GetCompatSchemaVersion(), version) < 0) { m_Pgsql->finish(m_Connection); SetConnected(false); Log(LogCritical, "IdoPgsqlConnection") << "Schema version '" << version << "' does not match the required version '" - << IDO_COMPAT_SCHEMA_VERSION << "' (or newer)! Please check the upgrade documentation at " + << GetCompatSchemaVersion() << "' (or newer)! Please check the upgrade documentation at " << "https://icinga.com/docs/icinga2/latest/doc/16-upgrading-icinga-2/#upgrading-postgresql-db"; BOOST_THROW_EXCEPTION(std::runtime_error("Schema version mismatch.")); diff --git a/lib/db_ido_pgsql/idopgsqlconnection.hpp b/lib/db_ido_pgsql/idopgsqlconnection.hpp index 2a978bf3d..a2ffb2e7e 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.hpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.hpp @@ -31,6 +31,7 @@ public: static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); const char * GetLatestSchemaVersion() const noexcept override; + const char * GetCompatSchemaVersion() const noexcept override; int GetPendingQueryCount() const override;