Skip to content

Commit 7ff76cb

Browse files
authored
Protect upgrades from failures (#12319)
1 parent 7a11bd2 commit 7ff76cb

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- in cloud
19+
DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_DROP_COLUMN`;
20+
21+
-- Error 1091: Can't DROP column; check that column/key exists
22+
CREATE PROCEDURE `cloud`.`IDEMPOTENT_DROP_COLUMN` (
23+
IN in_table_name VARCHAR(200),
24+
IN in_column_name VARCHAR(200)
25+
)
26+
BEGIN
27+
28+
DECLARE CONTINUE HANDLER FOR 1091 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name, ' DROP COLUMN ', in_column_name); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ CALL `cloud`.`IDEMPOTENT_DROP_FOREIGN_KEY`('cloud.service_offering','fk_service_
301301
CALL `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY`('cloud.service_offering', 'fk_service_offering__vgpu_profile_id', '(vgpu_profile_id)', '`vgpu_profile`(`id`)');
302302

303303
-- Netris Plugin
304-
CREATE TABLE `cloud`.`netris_providers` (
304+
CREATE TABLE IF NOT EXISTS `cloud`.`netris_providers` (
305305
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
306306
`uuid` varchar(40),
307307
`zone_id` bigint unsigned NOT NULL COMMENT 'Zone ID',
@@ -321,11 +321,11 @@ CREATE TABLE `cloud`.`netris_providers` (
321321
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
322322

323323
-- Drop the Tungsten and NSX columns from the network offerings (replaced by checking the provider on the ntwk_offering_service_map table)
324-
ALTER TABLE `cloud`.`network_offerings` DROP COLUMN `for_tungsten`;
325-
ALTER TABLE `cloud`.`network_offerings` DROP COLUMN `for_nsx`;
324+
CALL `cloud`.`IDEMPOTENT_DROP_COLUMN`('cloud.network_offerings', 'for_tungsten');
325+
CALL `cloud`.`IDEMPOTENT_DROP_COLUMN`('cloud.network_offerings', 'for_nsx');
326326

327327
-- Drop the Tungsten and NSX columns from the VPC offerings (replaced by checking the provider on the vpc_offering_service_map table)
328-
ALTER TABLE `cloud`.`vpc_offerings` DROP COLUMN `for_nsx`;
328+
CALL `cloud`.`IDEMPOTENT_DROP_COLUMN`('cloud.vpc_offerings', 'for_nsx');
329329

330330
-- Add next_hop to the static_routes table
331331
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.static_routes', 'next_hop', 'varchar(50) COMMENT "next hop of the static route" AFTER `vpc_gateway_id`');

0 commit comments

Comments
 (0)