Skip to content

Commit 328044e

Browse files
committed
fix upgrade path
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent ca80255 commit 328044e

5 files changed

Lines changed: 104 additions & 33 deletions

File tree

engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333

3434
import javax.inject.Inject;
3535

36-
import com.cloud.utils.FileUtil;
3736
import org.apache.cloudstack.utils.CloudStackVersion;
3837
import org.apache.commons.lang3.StringUtils;
39-
import org.apache.logging.log4j.Logger;
4038
import org.apache.logging.log4j.LogManager;
39+
import org.apache.logging.log4j.Logger;
4140

4241
import com.cloud.upgrade.dao.DbUpgrade;
4342
import com.cloud.upgrade.dao.DbUpgradeSystemVmTemplate;
@@ -90,9 +89,10 @@
9089
import com.cloud.upgrade.dao.Upgrade41910to42000;
9190
import com.cloud.upgrade.dao.Upgrade42000to42010;
9291
import com.cloud.upgrade.dao.Upgrade42010to42100;
93-
import com.cloud.upgrade.dao.Upgrade42100to42200;
9492
import com.cloud.upgrade.dao.Upgrade420to421;
93+
import com.cloud.upgrade.dao.Upgrade42100to42200;
9594
import com.cloud.upgrade.dao.Upgrade421to430;
95+
import com.cloud.upgrade.dao.Upgrade42200to42300;
9696
import com.cloud.upgrade.dao.Upgrade430to440;
9797
import com.cloud.upgrade.dao.Upgrade431to440;
9898
import com.cloud.upgrade.dao.Upgrade432to440;
@@ -121,6 +121,7 @@
121121
import com.cloud.upgrade.dao.VersionDaoImpl;
122122
import com.cloud.upgrade.dao.VersionVO;
123123
import com.cloud.upgrade.dao.VersionVO.Step;
124+
import com.cloud.utils.FileUtil;
124125
import com.cloud.utils.component.SystemIntegrityChecker;
125126
import com.cloud.utils.crypt.DBEncryptionUtil;
126127
import com.cloud.utils.db.GlobalLock;
@@ -236,6 +237,7 @@ public DatabaseUpgradeChecker() {
236237
.next("4.20.0.0", new Upgrade42000to42010())
237238
.next("4.20.1.0", new Upgrade42010to42100())
238239
.next("4.21.0.0", new Upgrade42100to42200())
240+
.next("4.22.0.0", new Upgrade42200to42300())
239241
.build();
240242
}
241243

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
package com.cloud.upgrade.dao;
18+
19+
public class Upgrade42200to42300 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
20+
21+
@Override
22+
public String[] getUpgradableVersionRange() {
23+
return new String[]{"4.22.0.0", "4.23.0.0"};
24+
}
25+
26+
@Override
27+
public String getUpgradedVersion() {
28+
return "4.23.0.0";
29+
}
30+
}

engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,33 +87,3 @@ CALL `cloud`.`INSERT_EXTENSION_DETAIL_IF_NOT_EXISTS`('MaaS', 'orchestratorrequir
8787

8888
CALL `cloud`.`IDEMPOTENT_DROP_UNIQUE_KEY`('counter', 'uc_counter__provider__source__value');
8989
CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.counter', 'uc_counter__provider__source__value__removed', '(provider, source, value, removed)');
90-
91-
-- ToDo: Move to 4.23 upgrade path
92-
-- Add management_server_details table to allow ManagementServer scope configs
93-
CREATE TABLE IF NOT EXISTS `cloud`.`management_server_details` (
94-
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
95-
`management_server_id` bigint unsigned NOT NULL COMMENT 'management server the detail is related to',
96-
`name` varchar(255) NOT NULL COMMENT 'name of the detail',
97-
`value` varchar(255) NOT NULL,
98-
`display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user',
99-
PRIMARY KEY (`id`),
100-
CONSTRAINT `fk_management_server_details__management_server_id` FOREIGN KEY `fk_management_server_details__management_server_id`(`management_server_id`) REFERENCES `mshost`(`id`) ON DELETE CASCADE,
101-
KEY `i_management_server_details__name__value` (`name`(128),`value`(128))
102-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
103-
104-
-- Create table for logs web session
105-
CREATE TABLE IF NOT EXISTS `cloud`.`logs_web_session` (
106-
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the session',
107-
`uuid` varchar(40) NOT NULL COMMENT 'UUID generated for the session',
108-
`filter` varchar(64) DEFAULT NULL COMMENT 'Filter keyword for the session',
109-
`created` datetime NOT NULL COMMENT 'When the session was created',
110-
`domain_id` bigint(20) unsigned NOT NULL COMMENT 'Domain of the account who generated the session',
111-
`account_id` bigint(20) unsigned NOT NULL COMMENT 'Account who generated the session',
112-
`creator_address` VARCHAR(45) DEFAULT NULL COMMENT 'Address of the creator of the session',
113-
`connections` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of connections for the session',
114-
`connected_time` datetime DEFAULT NULL COMMENT 'When the session was connected',
115-
`client_address` VARCHAR(45) DEFAULT NULL COMMENT 'Address of the client that connected to the session',
116-
`removed` datetime COMMENT 'When the session was removed/used',
117-
PRIMARY KEY(`id`),
118-
CONSTRAINT `uc_logs_web_session__uuid` UNIQUE (`uuid`)
119-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
--;
19+
-- Schema upgrade cleanup from 4.22.0.0 to 4.23.0.0
20+
--;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
--;
19+
-- Schema upgrade from 4.22.0.0 to 4.23.0.0
20+
--;
21+
22+
-- Add management_server_details table to allow ManagementServer scope configs
23+
CREATE TABLE IF NOT EXISTS `cloud`.`management_server_details` (
24+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
25+
`management_server_id` bigint unsigned NOT NULL COMMENT 'management server the detail is related to',
26+
`name` varchar(255) NOT NULL COMMENT 'name of the detail',
27+
`value` varchar(255) NOT NULL,
28+
`display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user',
29+
PRIMARY KEY (`id`),
30+
CONSTRAINT `fk_management_server_details__management_server_id` FOREIGN KEY `fk_management_server_details__management_server_id`(`management_server_id`) REFERENCES `mshost`(`id`) ON DELETE CASCADE,
31+
KEY `i_management_server_details__name__value` (`name`(128),`value`(128))
32+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
33+
34+
-- Create table for logs web session
35+
CREATE TABLE IF NOT EXISTS `cloud`.`logs_web_session` (
36+
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the session',
37+
`uuid` varchar(40) NOT NULL COMMENT 'UUID generated for the session',
38+
`filter` varchar(64) DEFAULT NULL COMMENT 'Filter keyword for the session',
39+
`created` datetime NOT NULL COMMENT 'When the session was created',
40+
`domain_id` bigint(20) unsigned NOT NULL COMMENT 'Domain of the account who generated the session',
41+
`account_id` bigint(20) unsigned NOT NULL COMMENT 'Account who generated the session',
42+
`creator_address` VARCHAR(45) DEFAULT NULL COMMENT 'Address of the creator of the session',
43+
`connections` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of connections for the session',
44+
`connected_time` datetime DEFAULT NULL COMMENT 'When the session was connected',
45+
`client_address` VARCHAR(45) DEFAULT NULL COMMENT 'Address of the client that connected to the session',
46+
`removed` datetime COMMENT 'When the session was removed/used',
47+
PRIMARY KEY(`id`),
48+
CONSTRAINT `uc_logs_web_session__uuid` UNIQUE (`uuid`)
49+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

0 commit comments

Comments
 (0)