Skip to content

Commit

Permalink
Increase database schema version
Browse files Browse the repository at this point in the history
The removal of the `NOT NULL` constraint on `customvar_flat`.`flat_value` makes
the schema upgrade a hard requirement for 1.1.1.
  • Loading branch information
julianbrost committed Aug 7, 2023
1 parent 7a2ab2d commit 653f356
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/icingadb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion schema/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
3 changes: 3 additions & 0 deletions schema/mysql/upgrades/1.1.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion schema/pgsql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
3 changes: 3 additions & 0 deletions schema/pgsql/upgrades/1.1.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 653f356

Please sign in to comment.