diff --git a/LibreNMS/DB/Schema.php b/LibreNMS/DB/Schema.php index 073e6a1ba2..961784bedc 100644 --- a/LibreNMS/DB/Schema.php +++ b/LibreNMS/DB/Schema.php @@ -346,6 +346,8 @@ class Schema $output = []; $db_name = DB::connection($connection)->getDatabaseName(); + DB::statement("SET TIME_ZONE='+00:00'"); // set timezone to UTC to avoid timezone issues + foreach (DB::connection($connection)->select(DB::raw("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '$db_name' ORDER BY TABLE_NAME;")) as $table) { $table = $table->TABLE_NAME; foreach (DB::connection($connection)->select(DB::raw("SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, EXTRA FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '$db_name' AND TABLE_NAME='$table' ORDER BY ORDINAL_POSITION")) as $data) { diff --git a/LibreNMS/Validations/Database.php b/LibreNMS/Validations/Database.php index dcdab8540a..2405eb0686 100644 --- a/LibreNMS/Validations/Database.php +++ b/LibreNMS/Validations/Database.php @@ -319,6 +319,11 @@ class Database extends BaseValidation $schema_update[] = $this->dropTableSql($table); } + // set utc timezone if timestamp issues + if (preg_grep('/\d{4}-\d\d-\d\d \d\d:\d\d:\d\d/', $schema_update)) { + array_unshift($schema_update, "SET TIME_ZONE='+00:00';"); + } + if (empty($schema_update)) { $validator->ok('Database schema correct'); } else {