mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
schema: Add upgrade path from 4.21.0.0 to 4.22.0.0 (#11469)
* Add upgrade path from 4.21.0.0 to 4.22.0.0 * Optimize DbUpgrade files
This commit is contained in:
parent
2eb80e0361
commit
889fc62b60
@ -90,6 +90,7 @@ import com.cloud.upgrade.dao.Upgrade41900to41910;
|
|||||||
import com.cloud.upgrade.dao.Upgrade41910to42000;
|
import com.cloud.upgrade.dao.Upgrade41910to42000;
|
||||||
import com.cloud.upgrade.dao.Upgrade42000to42010;
|
import com.cloud.upgrade.dao.Upgrade42000to42010;
|
||||||
import com.cloud.upgrade.dao.Upgrade42010to42100;
|
import com.cloud.upgrade.dao.Upgrade42010to42100;
|
||||||
|
import com.cloud.upgrade.dao.Upgrade42100to42200;
|
||||||
import com.cloud.upgrade.dao.Upgrade420to421;
|
import com.cloud.upgrade.dao.Upgrade420to421;
|
||||||
import com.cloud.upgrade.dao.Upgrade421to430;
|
import com.cloud.upgrade.dao.Upgrade421to430;
|
||||||
import com.cloud.upgrade.dao.Upgrade430to440;
|
import com.cloud.upgrade.dao.Upgrade430to440;
|
||||||
@ -234,6 +235,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
|||||||
.next("4.19.1.0", new Upgrade41910to42000())
|
.next("4.19.1.0", new Upgrade41910to42000())
|
||||||
.next("4.20.0.0", new Upgrade42000to42010())
|
.next("4.20.0.0", new Upgrade42000to42010())
|
||||||
.next("4.20.1.0", new Upgrade42010to42100())
|
.next("4.20.1.0", new Upgrade42010to42100())
|
||||||
|
.next("4.21.0.0", new Upgrade42100to42200())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.upgrade.dao;
|
package com.cloud.upgrade.dao;
|
||||||
|
|
||||||
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
|
||||||
@ -24,20 +26,43 @@ public interface DbUpgrade {
|
|||||||
|
|
||||||
String getUpgradedVersion();
|
String getUpgradedVersion();
|
||||||
|
|
||||||
boolean supportsRollingUpgrade();
|
default boolean supportsRollingUpgrade() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the script to prepare the database schema for the
|
* @return the script to prepare the database schema for the
|
||||||
* data migration step.
|
* data migration step.
|
||||||
*/
|
*/
|
||||||
InputStream[] getPrepareScripts();
|
default InputStream[] getPrepareScripts() {
|
||||||
|
String fromVersion = getUpgradableVersionRange()[0];
|
||||||
|
String toVersion = getUpgradableVersionRange()[1];
|
||||||
|
final String scriptFile = String.format("META-INF/db/schema-%sto%s.sql", fromVersion.replace(".", ""), toVersion.replace(".", ""));
|
||||||
|
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||||
|
if (script == null) {
|
||||||
|
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new InputStream[]{script};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the actual data migration.
|
* Performs the actual data migration.
|
||||||
*/
|
*/
|
||||||
void performDataMigration(Connection conn);
|
default void performDataMigration(Connection conn) {
|
||||||
|
}
|
||||||
|
|
||||||
InputStream[] getCleanupScripts();
|
default InputStream[] getCleanupScripts() {
|
||||||
|
String fromVersion = getUpgradableVersionRange()[0];
|
||||||
|
String toVersion = getUpgradableVersionRange()[1];
|
||||||
|
final String scriptFile = String.format("META-INF/db/schema-%sto%s-cleanup.sql", fromVersion.replace(".", ""), toVersion.replace(".", ""));
|
||||||
|
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||||
|
if (script == null) {
|
||||||
|
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new InputStream[]{script};
|
||||||
|
}
|
||||||
|
|
||||||
default boolean refreshPoolConnectionsAfterUpgrade() {
|
default boolean refreshPoolConnectionsAfterUpgrade() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -17,9 +17,23 @@
|
|||||||
|
|
||||||
package com.cloud.upgrade.dao;
|
package com.cloud.upgrade.dao;
|
||||||
|
|
||||||
|
import com.cloud.upgrade.SystemVmTemplateRegistration;
|
||||||
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
|
||||||
public interface DbUpgradeSystemVmTemplate {
|
public interface DbUpgradeSystemVmTemplate {
|
||||||
|
|
||||||
void updateSystemVmTemplates(Connection conn);
|
default void updateSystemVmTemplates(Connection conn) {
|
||||||
|
Logger logger = LogManager.getLogger(getClass());
|
||||||
|
logger.debug("Updating System Vm template IDs");
|
||||||
|
try {
|
||||||
|
SystemVmTemplateRegistration systemVmTemplateRegistration = new SystemVmTemplateRegistration("");
|
||||||
|
systemVmTemplateRegistration.updateSystemVmTemplates(conn);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
// 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.
|
||||||
|
package com.cloud.upgrade.dao;
|
||||||
|
|
||||||
|
public class Upgrade42100to42200 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getUpgradableVersionRange() {
|
||||||
|
return new String[]{"4.21.0.0", "4.22.0.0"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUpgradedVersion() {
|
||||||
|
return "4.22.0.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
--;
|
||||||
|
-- Schema upgrade cleanup from 4.21.0.0 to 4.22.0.0
|
||||||
|
--;
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
--;
|
||||||
|
-- Schema upgrade from 4.21.0.0 to 4.22.0.0
|
||||||
|
--;
|
||||||
Loading…
x
Reference in New Issue
Block a user