This is an automated email from the ASF dual-hosted git repository.

pearl11594 pushed a commit to branch fix-netris-columns
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 3b8d7d186245b5fa0fb4d90c5c4146b993f30271
Author: Pearl Dsilva <[email protected]>
AuthorDate: Mon Dec 22 08:44:53 2025 -0500

    Protect upgrades from failures
---
 .../db/procedures/cloud.idempotent_drop_column.sql | 31 ++++++++++++++++++++++
 .../resources/META-INF/db/schema-42010to42100.sql  |  8 +++---
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git 
a/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_drop_column.sql
 
b/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_drop_column.sql
new file mode 100644
index 00000000000..f8bbff143c1
--- /dev/null
+++ 
b/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_drop_column.sql
@@ -0,0 +1,31 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_DROP_COLUMN`;
+
+CREATE PROCEDURE `cloud`.`IDEMPOTENT_DROP_COLUMN` (
+    IN in_table_name VARCHAR(200),
+    IN in_column_name VARCHAR(200)
+)
+BEGIN
+    DECLARE CONTINUE HANDLER FOR 1091 BEGIN END; -- Error 1091: Can't DROP 
column; check that column/key exists
+    SET @stmt = CONCAT('ALTER TABLE ', in_table_name, ' DROP COLUMN ', 
in_column_name);
+    PREPARE stmt FROM @stmt;
+    EXECUTE stmt;
+    DEALLOCATE PREPARE stmt;
+END;
+
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql
index 167dd92730c..4c65f37e0fe 100644
--- a/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql
+++ b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql
@@ -301,7 +301,7 @@ CALL 
`cloud`.`IDEMPOTENT_DROP_FOREIGN_KEY`('cloud.service_offering','fk_service_
 CALL `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY`('cloud.service_offering', 
'fk_service_offering__vgpu_profile_id', '(vgpu_profile_id)', 
'`vgpu_profile`(`id`)');
 
 -- Netris Plugin
-CREATE TABLE `cloud`.`netris_providers` (
+CREATE TABLE IF NOT EXISTS `cloud`.`netris_providers` (
                                             `id` bigint unsigned NOT NULL 
auto_increment COMMENT 'id',
                                             `uuid` varchar(40),
                                             `zone_id` bigint unsigned NOT NULL 
COMMENT 'Zone ID',
@@ -321,11 +321,11 @@ CREATE TABLE `cloud`.`netris_providers` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 -- Drop the Tungsten and NSX columns from the network offerings (replaced by 
checking the provider on the ntwk_offering_service_map table)
-ALTER TABLE `cloud`.`network_offerings` DROP COLUMN `for_tungsten`;
-ALTER TABLE `cloud`.`network_offerings` DROP COLUMN `for_nsx`;
+CALL `cloud`.`IDEMPOTENT_DROP_COLUMN`('cloud.network_offerings', 
'for_tungsten');
+CALL `cloud`.`IDEMPOTENT_DROP_COLUMN`('cloud.network_offerings', 'for_nsx');
 
 -- Drop the Tungsten and NSX columns from the VPC offerings (replaced by 
checking the provider on the vpc_offering_service_map table)
-ALTER TABLE `cloud`.`vpc_offerings` DROP COLUMN `for_nsx`;
+CALL `cloud`.`IDEMPOTENT_DROP_COLUMN`('cloud.vpc_offerings', 'for_nsx');
 
 -- Add next_hop to the static_routes table
 CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.static_routes', 'next_hop', 
'varchar(50) COMMENT "next hop of the static route" AFTER `vpc_gateway_id`');

Reply via email to