diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41811to41812.sql b/engine/schema/src/main/resources/META-INF/db/schema-41811to41812.sql index 5a72bd42153..c5cdedf0168 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41811to41812.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41811to41812.sql @@ -44,7 +44,23 @@ INSERT IGNORE INTO `cloud`.`configuration` ( 'Connect PowerFlex client on Host when first Volume created and disconnect when last Volume deleted (or always stay connected otherwise).' ); -CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.resource_reservation', 'mgmt_server_id', 'bigint unsigned NULL COMMENT "management server id" '); -CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.resource_reservation', 'created', 'datetime DEFAULT NULL COMMENT "date when the reservation was created" '); - -UPDATE `cloud`.`resource_reservation` SET `created` = now() WHERE `created` IS NULL; +-- These fields have been added in 4.18.0, however due to issues with update process (sql updated after version update) +-- adding one more time here in case if migration from 4.18.0 didn't go through +CREATE PROCEDURE `cloud`.`ADD_RESOURCE_RESERVATION_MGMT_SERVER_ID_CREATED`() +BEGIN + DECLARE created_exists TINYINT DEFAULT FALSE +; IF NOT EXISTS (SELECT * FROM `information_schema`.`columns` WHERE `table_schema` = 'cloud' AND `table_name` = 'resource_reservation' AND `column_name` = 'mgmt_server_id') THEN + CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.resource_reservation', 'mgmt_server_id', 'bigint unsigned NULL COMMENT "management server id" ') +; END IF +; IF NOT EXISTS (SELECT * FROM `information_schema`.`columns` WHERE `table_schema` = 'cloud' AND `table_name` = 'resource_reservation' AND `column_name` = 'created') THEN + SET created_exists = TRUE +; END IF +; IF created_exists THEN + CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.resource_reservation', 'created', 'datetime DEFAULT NULL COMMENT "date when the reservation was created" ') +; END IF +; IF created_exists THEN + UPDATE `cloud`.`resource_reservation` SET `created` = now() WHERE `created` IS NULL +; END IF +; END; +CALL `cloud`.`ADD_RESOURCE_RESERVATION_MGMT_SERVER_ID_CREATED`(); +DROP PROCEDURE IF EXISTS `cloud`.`ADD_RESOURCE_RESERVATION_MGMT_SERVER_ID_CREATED`;