Skip to content

Commit

Permalink
Icinga#2885 Fix MySQL8.4 nonstandard foreign keys deprecation
Browse files Browse the repository at this point in the history
If you try to set up icinga director with the latest minor version of MySQL 8.4+, the schema creation will fail with confusing SQL error messages. This commit aims to fix that. https://dev.mysql.com/doc/refman/8.4/en/mysql-nutshell.html#mysql-nutshell-deprecations
  • Loading branch information
mcsken committed Dec 19, 2024
1 parent de8fe10 commit 253a22e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
13 changes: 13 additions & 0 deletions schema/mysql-migrations/upgrade_188.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALTER TABLE director_activity_log
ADD UNIQUE INDEX idx_checksum (checksum);

ALTER TABLE director_generated_config
ADD CONSTRAINT fk_director_generated_config_activity
FOREIGN KEY (last_activity_checksum)
REFERENCES director_activity_log(checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (188, NOW());
12 changes: 7 additions & 5 deletions schema/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ CREATE TABLE director_activity_log (
INDEX search_idx (object_name),
INDEX search_idx2 (object_type(32), object_name(64), change_time),
INDEX search_author (author),
INDEX checksum (checksum)
INDEX checksum (checksum),
UNIQUE INDEX idx_checksum (checksum)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE director_activity_log_remark (
Expand Down Expand Up @@ -113,9 +114,10 @@ CREATE TABLE director_generated_config (
first_activity_checksum VARBINARY(20) NOT NULL,
last_activity_checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (checksum),
CONSTRAINT director_generated_config_activity
FOREIGN KEY activity_checksum (last_activity_checksum)
REFERENCES director_activity_log (checksum)
INDEX idx_checksum (checksum),
CONSTRAINT fk_director_generated_config_activity
FOREIGN KEY (last_activity_checksum)
REFERENCES director_activity_log(checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Expand Down Expand Up @@ -2446,4 +2448,4 @@ CREATE TABLE branched_icinga_dependency (

INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (187, NOW());
VALUES (188, NOW());

0 comments on commit 253a22e

Please sign in to comment.