From 5d3b5795deeab089ef13c95836ac2d72b0a92846 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Thu, 3 Aug 2023 16:50:02 +0200 Subject: [PATCH] Increase database schema version The removal of the `NOT NULL` constraint on `customvar_flat`.`flat_value` makes the schema upgrade a hard requirement for 1.1.1. --- pkg/icingadb/db.go | 4 ++-- schema/mysql/schema.sql | 2 +- schema/mysql/upgrades/1.1.1.sql | 3 +++ schema/pgsql/schema.sql | 2 +- schema/pgsql/upgrades/1.1.1.sql | 3 +++ 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/icingadb/db.go b/pkg/icingadb/db.go index 0beca180f..4ff3e0dde 100644 --- a/pkg/icingadb/db.go +++ b/pkg/icingadb/db.go @@ -85,8 +85,8 @@ func NewDb(db *sqlx.DB, logger *logging.Logger, options *Options) *DB { } const ( - expectedMysqlSchemaVersion = 3 - expectedPostgresSchemaVersion = 1 + expectedMysqlSchemaVersion = 4 + expectedPostgresSchemaVersion = 2 ) // CheckSchema asserts the database schema of the expected version being present. diff --git a/schema/mysql/schema.sql b/schema/mysql/schema.sql index 497ebba5f..f4434f139 100644 --- a/schema/mysql/schema.sql +++ b/schema/mysql/schema.sql @@ -1343,4 +1343,4 @@ CREATE TABLE icingadb_schema ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; INSERT INTO icingadb_schema (version, timestamp) - VALUES (3, CURRENT_TIMESTAMP() * 1000); + VALUES (4, CURRENT_TIMESTAMP() * 1000); diff --git a/schema/mysql/upgrades/1.1.1.sql b/schema/mysql/upgrades/1.1.1.sql index 360e4d5d9..264ecae3e 100644 --- a/schema/mysql/upgrades/1.1.1.sql +++ b/schema/mysql/upgrades/1.1.1.sql @@ -32,3 +32,6 @@ ALTER TABLE history DROP COLUMN event_type, CHANGE COLUMN event_type_new event_type enum('state_change', 'ack_clear', 'downtime_end', 'flapping_end', 'comment_remove', 'comment_add', 'flapping_start', 'downtime_start', 'ack_set', 'notification') NOT NULL; UNLOCK TABLES; + +INSERT INTO icingadb_schema (version, timestamp) + VALUES (4, CURRENT_TIMESTAMP() * 1000); diff --git a/schema/pgsql/schema.sql b/schema/pgsql/schema.sql index 491e9136a..9027fac52 100644 --- a/schema/pgsql/schema.sql +++ b/schema/pgsql/schema.sql @@ -2181,4 +2181,4 @@ CREATE TABLE icingadb_schema ( ALTER SEQUENCE icingadb_schema_id_seq OWNED BY icingadb_schema.id; INSERT INTO icingadb_schema (version, timestamp) - VALUES (1, extract(epoch from now()) * 1000); + VALUES (2, extract(epoch from now()) * 1000); diff --git a/schema/pgsql/upgrades/1.1.1.sql b/schema/pgsql/upgrades/1.1.1.sql index 89f403b56..ed12ed71b 100644 --- a/schema/pgsql/upgrades/1.1.1.sql +++ b/schema/pgsql/upgrades/1.1.1.sql @@ -25,3 +25,6 @@ ALTER TABLE history ALTER COLUMN event_type TYPE history_type USING event_type::text::history_type, ALTER COLUMN event_type SET DEFAULT 'state_change'::history_type; DROP TYPE history_type_old; + +INSERT INTO icingadb_schema (version, timestamp) + VALUES (2, extract(epoch from now()) * 1000);