Skip to content

Commit f155caa

Browse files
committed
add upgrade path
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 65d673f commit f155caa

4 files changed

Lines changed: 123 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import com.cloud.upgrade.dao.Upgrade41120to41130;
6767
import com.cloud.upgrade.dao.Upgrade41120to41200;
6868
import com.cloud.upgrade.dao.Upgrade41200to41300;
69+
import com.cloud.upgrade.dao.Upgrade41300to41400;
6970
import com.cloud.upgrade.dao.Upgrade420to421;
7071
import com.cloud.upgrade.dao.Upgrade421to430;
7172
import com.cloud.upgrade.dao.Upgrade430to440;
@@ -187,6 +188,7 @@ public DatabaseUpgradeChecker() {
187188
.next("4.11.2.0", new Upgrade41120to41130())
188189
.next("4.11.3.0", new Upgrade41120to41200())
189190
.next("4.12.0.0", new Upgrade41200to41300())
191+
.next("4.13.0.0", new Upgrade41300to41400())
190192
.build();
191193
}
192194

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
package com.cloud.upgrade.dao;
19+
20+
import java.io.InputStream;
21+
import java.sql.Connection;
22+
import java.sql.PreparedStatement;
23+
import java.sql.ResultSet;
24+
import java.sql.SQLException;
25+
import java.util.HashMap;
26+
import java.util.HashSet;
27+
import java.util.Map;
28+
import java.util.Set;
29+
30+
import org.apache.log4j.Logger;
31+
32+
import com.cloud.hypervisor.Hypervisor;
33+
import com.cloud.utils.exception.CloudRuntimeException;
34+
35+
public class Upgrade41300to41400 implements DbUpgrade {
36+
37+
final static Logger LOG = Logger.getLogger(Upgrade41300to41400.class);
38+
39+
@Override
40+
public String[] getUpgradableVersionRange() {
41+
return new String[] {"4.13.0.0", "4.14.0.0"};
42+
}
43+
44+
@Override
45+
public String getUpgradedVersion() {
46+
return "4.14.0.0";
47+
}
48+
49+
@Override
50+
public boolean supportsRollingUpgrade() {
51+
return false;
52+
}
53+
54+
@Override
55+
public InputStream[] getPrepareScripts() {
56+
final String scriptFile = "META-INF/db/schema-41300to41400.sql";
57+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
58+
if (script == null) {
59+
throw new CloudRuntimeException("Unable to find " + scriptFile);
60+
}
61+
62+
return new InputStream[] {script};
63+
}
64+
65+
@Override
66+
public void performDataMigration(Connection conn) {
67+
}
68+
69+
@Override
70+
public InputStream[] getCleanupScripts() {
71+
final String scriptFile = "META-INF/db/schema-41300to41400-cleanup.sql";
72+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
73+
if (script == null) {
74+
throw new CloudRuntimeException("Unable to find " + scriptFile);
75+
}
76+
77+
return new InputStream[] {script};
78+
}
79+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.13.0.0 to 4.14.0.0
20+
--;
21+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.13.0.0 to 4.14.0.0
20+
--;
21+

0 commit comments

Comments
 (0)