From 253a22e9b7b59bbf9a1569b56b37946fadb9c8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mek=20Sk=C3=ABndo?= Date: Thu, 19 Dec 2024 16:56:04 +0100 Subject: [PATCH] #2885 Fix MySQL8.4 nonstandard foreign keys deprecation 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 --- schema/mysql-migrations/upgrade_188.sql | 13 +++++++++++++ schema/mysql.sql | 12 +++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 schema/mysql-migrations/upgrade_188.sql diff --git a/schema/mysql-migrations/upgrade_188.sql b/schema/mysql-migrations/upgrade_188.sql new file mode 100644 index 000000000..44451836a --- /dev/null +++ b/schema/mysql-migrations/upgrade_188.sql @@ -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()); diff --git a/schema/mysql.sql b/schema/mysql.sql index 832ab122d..26a6799fc 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -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 ( @@ -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; @@ -2446,4 +2448,4 @@ CREATE TABLE branched_icinga_dependency ( INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (187, NOW()); + VALUES (188, NOW());