Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: Add dependency additions #795

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions schema/mysql/upgrades/dependencies.sql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my testing, I have added the environment ID as environment_id BINARY(20) NOT NULL to most tables.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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,
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;

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The redundancy_group_state table is missing last_state_change column, to track how long since the redundancy group has failed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that now it's there twice. Please refer to my other comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems I mixed things up here a bit. dependencies.sql was the initial script and seemingly intended as full upgrade whereas the other files, 2 and 3, are partial upgrades. Though changes made in 3 didn't made it into the full upgrade. :D

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` (
`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;
Loading