Skip to content

Commit 3b8d7d1

Browse files
committed
Protect upgrades from failures
1 parent 8936e4c commit 3b8d7d1

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_DROP_COLUMN`;
19+
20+
CREATE PROCEDURE `cloud`.`IDEMPOTENT_DROP_COLUMN` (
21+
IN in_table_name VARCHAR(200),
22+
IN in_column_name VARCHAR(200)
23+
)
24+
BEGIN
25+
DECLARE CONTINUE HANDLER FOR 1091 BEGIN END; -- Error 1091: Can't DROP column; check that column/key exists
26+
SET @stmt = CONCAT('ALTER TABLE ', in_table_name, ' DROP COLUMN ', in_column_name);
27+
PREPARE stmt FROM @stmt;
28+
EXECUTE stmt;
29+
DEALLOCATE PREPARE stmt;
30+
END;
31+

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)