From 0ca683912f96e8372b1408e92bae8013a67fd605 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Sep 2024 16:26:36 +0200 Subject: [PATCH 1/4] schema/mysql: Add upgrade for dependency additions --- schema/mysql/upgrades/dependencies.sql | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 schema/mysql/upgrades/dependencies.sql diff --git a/schema/mysql/upgrades/dependencies.sql b/schema/mysql/upgrades/dependencies.sql new file mode 100644 index 000000000..bc8c267dd --- /dev/null +++ b/schema/mysql/upgrades/dependencies.sql @@ -0,0 +1,53 @@ +CREATE TABLE `dependency` ( + `id` binary(20) NOT NULL, + `name` text NOT NULL, + `display_name` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; + +CREATE TABLE `dependency_state` ( + `id` binary(20) NOT NULL, + `dependency_id` binary(20) NOT NULL, + `failed` enum('n', 'y') NOT NULL, + KEY `dependency_state_dependency_id_fk` (`dependency_id`), + CONSTRAINT `dependency_state_dependency_id_fk` FOREIGN KEY (`dependency_id`) REFERENCES `dependency` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; + +CREATE TABLE `redundancy_group` ( + `id` binary(20) NOT NULL, + `name` text NOT NULL, + `display_name` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; + +CREATE TABLE `redundancy_group_state` ( + `id` binary(20) NOT NULL, + `redundancy_group_id` binary(20) NOT NULL, + `failed` enum('n', 'y') NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; + +CREATE TABLE `dependency_node` ( + `id` binary(20) NOT NULL, + `host_id` binary(20) DEFAULT NULL, + `service_id` binary(20) DEFAULT NULL, + `redundancy_group_id` binary(20) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `dependency_node_host_id_service_id_uindex` (`host_id`,`service_id`), + KEY `dependency_node_redundancy_group_id_fk` (`redundancy_group_id`), + KEY `dependency_node_service_id_fk` (`service_id`), + CONSTRAINT `dependency_node_host_id_fk` FOREIGN KEY (`host_id`) REFERENCES `host` (`id`), + CONSTRAINT `dependency_node_redundancy_group_id_fk` FOREIGN KEY (`redundancy_group_id`) REFERENCES `redundancy_group` (`id`), + CONSTRAINT `dependency_node_service_id_fk` FOREIGN KEY (`service_id`) REFERENCES `service` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; + +CREATE TABLE `dependency_edge` ( + `to_node_id` binary(20) NOT NULL, + `from_node_id` binary(20) NOT NULL, + `dependency_id` binary(20) DEFAULT NULL, + UNIQUE KEY `dependency_edge_to_node_id_from_node_id_uindex` (`to_node_id`,`from_node_id`), + KEY `dependency_edge_dependency_node_id_fk_2` (`from_node_id`), + KEY `dependency_edge_dependency_id_fk` (`dependency_id`), + CONSTRAINT `dependency_edge_dependency_id_fk` FOREIGN KEY (`dependency_id`) REFERENCES `dependency` (`id`), + CONSTRAINT `dependency_edge_dependency_node_id_fk` FOREIGN KEY (`to_node_id`) REFERENCES `dependency_node` (`id`), + CONSTRAINT `dependency_edge_dependency_node_id_fk_2` FOREIGN KEY (`from_node_id`) REFERENCES `dependency_node` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; From e81e860e7260c7b4ec9bed879ce7a11cd2428bce Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Sep 2024 09:28:50 +0200 Subject: [PATCH 2/4] add missing keys/fks --- schema/mysql/upgrades/dependencies.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/schema/mysql/upgrades/dependencies.sql b/schema/mysql/upgrades/dependencies.sql index bc8c267dd..261b9769a 100644 --- a/schema/mysql/upgrades/dependencies.sql +++ b/schema/mysql/upgrades/dependencies.sql @@ -9,6 +9,7 @@ CREATE TABLE `dependency_state` ( `id` binary(20) NOT NULL, `dependency_id` binary(20) NOT NULL, `failed` enum('n', 'y') NOT NULL, + UNIQUE INDEX `dependency_state_dependency_id_uindex` (dependency_id), KEY `dependency_state_dependency_id_fk` (`dependency_id`), CONSTRAINT `dependency_state_dependency_id_fk` FOREIGN KEY (`dependency_id`) REFERENCES `dependency` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; @@ -23,7 +24,10 @@ CREATE TABLE `redundancy_group` ( CREATE TABLE `redundancy_group_state` ( `id` binary(20) NOT NULL, `redundancy_group_id` binary(20) NOT NULL, - `failed` enum('n', 'y') NOT NULL + `failed` enum('n', 'y') NOT NULL, + UNIQUE INDEX `redundancy_group_state_redundancy_group_id_uindex` (redundancy_group_id), + KEY `redundancy_group_state_redundancy_group_id_fk` (`redundancy_group_id`), + CONSTRAINT `redundancy_group_state_redundancy_group_id_fk` FOREIGN KEY (`redundancy_group_id`) REFERENCES `redundancy_group` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; CREATE TABLE `dependency_node` ( From 8206e6260f415a629e59755cd1ba56940ceea4a9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 11 Sep 2024 08:46:15 +0200 Subject: [PATCH 3/4] schema: add `last_state_change` to `redundancy_group_state` --- schema/mysql/upgrades/dependencies.sql | 1 + schema/mysql/upgrades/dependencies2.sql | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 schema/mysql/upgrades/dependencies2.sql diff --git a/schema/mysql/upgrades/dependencies.sql b/schema/mysql/upgrades/dependencies.sql index 261b9769a..bbfb38c0c 100644 --- a/schema/mysql/upgrades/dependencies.sql +++ b/schema/mysql/upgrades/dependencies.sql @@ -25,6 +25,7 @@ CREATE TABLE `redundancy_group_state` ( `id` binary(20) NOT NULL, `redundancy_group_id` binary(20) NOT NULL, `failed` enum('n', 'y') NOT NULL, + `last_state_change` bigint unsigned NOT NULL, UNIQUE INDEX `redundancy_group_state_redundancy_group_id_uindex` (redundancy_group_id), KEY `redundancy_group_state_redundancy_group_id_fk` (`redundancy_group_id`), CONSTRAINT `redundancy_group_state_redundancy_group_id_fk` FOREIGN KEY (`redundancy_group_id`) REFERENCES `redundancy_group` (`id`) diff --git a/schema/mysql/upgrades/dependencies2.sql b/schema/mysql/upgrades/dependencies2.sql new file mode 100644 index 000000000..364a137bd --- /dev/null +++ b/schema/mysql/upgrades/dependencies2.sql @@ -0,0 +1,2 @@ +alter table redundancy_group_state + add last_state_change bigint unsigned not null; From dbd05f20420ed986f8d36942ca6b3582cbc8d472 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 31 Oct 2024 14:37:17 +0100 Subject: [PATCH 4/4] mysql: Add affected_children and affects_children columns --- schema/mysql/upgrades/dependencies3.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 schema/mysql/upgrades/dependencies3.sql diff --git a/schema/mysql/upgrades/dependencies3.sql b/schema/mysql/upgrades/dependencies3.sql new file mode 100644 index 000000000..f67f42ad5 --- /dev/null +++ b/schema/mysql/upgrades/dependencies3.sql @@ -0,0 +1,11 @@ +ALTER TABLE host + ADD COLUMN affected_children int unsigned DEFAULT NULL AFTER check_retry_interval; + +ALTER TABLE host_state + ADD COLUMN affects_children enum('n', 'y') NOT NULL DEFAULT 'n' AFTER in_downtime; + +ALTER TABLE service + ADD COLUMN affected_children int unsigned DEFAULT NULL AFTER check_retry_interval; + +ALTER TABLE service_state + ADD COLUMN affects_children enum('n', 'y') NOT NULL DEFAULT 'n' AFTER in_downtime;