Icinga / icingaweb2-module-idoreports

Icinga IDO Reports provides host and service availability reports for Icinga based on the monitoring database (IDO).
GNU General Public License v2.0
34 stars 13 forks source link

ERROR 1067 (42000): Invalid default value for 'start_time' #42

Closed peter-snr closed 2 years ago

peter-snr commented 3 years ago

Describe the bug

When trying to create the new tables using the script supplied SQL Errors are produced.

To Reproduce

mysql> use icinga; mysql> source slaperiods.sql; Query OK, 0 rows affected, 1 warning (0.00 sec)

ERROR 1067 (42000): Invalid default value for 'start_time' Query OK, 0 rows affected, 1 warning (0.00 sec)

ERROR 1067 (42000): Invalid default value for 'start_time'

Expected behavior

The table to be created

Your Environment

Icinga Web 2 Version 2.8.1 Git commit 233bd29e4104125b4e5ef631e8c16dde33dadd9a PHP Version 7.3.11 Git commit date 2020-06-29

director | 1.7.2 doc | 2.8.1 idoreports | 0.9.0 incubator | 0.5.0 ipl | v0.5.0 monitoring | 2.8.1 pdfexport | 0.9.0 reactbundle | 0.7.0 reporting | 0.9.2 setup | 2.8.1 vspheredb | 1.1.0

peter-snr commented 3 years ago

After a bit of googling, I found a solutions that works. The default value for start_time was modified to 'CURRENT_TIMESTAMP' then I was able to successfully apply the script.

/usr/share/icingaweb2/modules/idoreports/schema/slaperiods.sql

SET sql_mode = '';
DROP TABLE IF EXISTS icinga_sla_periods;
CREATE TABLE icinga_sla_periods (
  timeperiod_object_id BIGINT(20) UNSIGNED NOT NULL,
  start_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  end_time timestamp NULL DEFAULT NULL,
  PRIMARY KEY tp_start (timeperiod_object_id, start_time),
  UNIQUE KEY tp_end (timeperiod_object_id, end_time)
) ENGINE InnoDB;

DROP TABLE IF EXISTS icinga_outofsla_periods;
CREATE TABLE icinga_outofsla_periods (
  timeperiod_object_id BIGINT(20) UNSIGNED NOT NULL,
  start_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  end_time timestamp NULL DEFAULT NULL,
  PRIMARY KEY tp_start (timeperiod_object_id, start_time),
  UNIQUE KEY tp_end (timeperiod_object_id, end_time)
) ENGINE InnoDB;
nilmerg commented 2 years ago

This is fixed in version 0.9.1.

nilmerg commented 2 years ago

Duplicate of #1