weizhouapache commented on code in PR #6202:
URL: https://github.com/apache/cloudstack/pull/6202#discussion_r884838462
##########
engine/schema/src/main/resources/META-INF/db/schema-41610to41700.sql:
##########
@@ -934,6 +934,330 @@ CREATE VIEW `cloud`.`event_view` AS
LEFT JOIN
`cloud`.`event` eve ON event.start_id = eve.id;
+CREATE TABLE `cloud`.`user_data` (
+ `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
+ `uuid` varchar(40) NOT NULL COMMENT 'UUID of the user data',
+ `name` varchar(256) NOT NULL COMMENT 'name of the user data',
+ `account_id` bigint unsigned NOT NULL COMMENT 'owner, foreign key to account
table',
+ `domain_id` bigint unsigned NOT NULL COMMENT 'domain, foreign key to domain
table',
+ `user_data` mediumtext COMMENT 'value of the userdata',
+ `params` mediumtext COMMENT 'value of the comma-separated list of
parameters',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_userdata__account_id` FOREIGN KEY(`account_id`) REFERENCES
`account` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_userdata__domain_id` FOREIGN KEY(`domain_id`) REFERENCES
`domain` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `uc_userdata__uuid` UNIQUE (`uuid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `cloud`.`user_vm` ADD COLUMN `user_data_id` bigint unsigned
DEFAULT NULL COMMENT 'id of the user data' AFTER `user_data`;
+ALTER TABLE `cloud`.`user_vm` ADD COLUMN `user_data_details` mediumtext
DEFAULT NULL COMMENT 'value of the comma-separated list of parameters' AFTER
`user_data_id`;
+ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__user_data_id`
FOREIGN KEY `fk_user_vm__user_data_id`(`user_data_id`) REFERENCES
`user_data`(`id`) ON DELETE CASCADE;
+
+ALTER TABLE `cloud`.`vm_template` ADD COLUMN `user_data_id` bigint unsigned
DEFAULT NULL COMMENT 'id of the user data';
+ALTER TABLE `cloud`.`vm_template` ADD COLUMN `user_data_link_policy`
varchar(255) DEFAULT NULL COMMENT 'user data link policy with template';
+ALTER TABLE `cloud`.`vm_template` ADD CONSTRAINT
`fk_vm_template__user_data_id` FOREIGN KEY
`fk_vm_template__user_data_id`(`user_data_id`) REFERENCES `user_data`(`id`) ON
DELETE CASCADE;
Review Comment:
@harikrishna-patnala
there is `user_data`(`id`) ON DELETE CASCADE` in line 953 and line 957,
which leads to the issue that the user_vm and vm_template records will be
removed from database when a userdata is removed.
please consider
(1) remove the `ON DELETE CASCADE`, OR
(2) add `removed` to `user_data` table so the record will not be removed
from database, OR
(3) do not allow deleltion of `user_data` if it is used by a user vm. (I
think the check on vm_template already exists)
3 is not good in my opinion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]