From e507b57b41d69ad7ce8008209b0742ca3cab03d2 Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Thu, 2 Sep 2021 11:57:38 -0300 Subject: [PATCH] Add 4.15.2 schema and upgrade path (#5403) --- .../cloud/upgrade/DatabaseUpgradeChecker.java | 2 + .../upgrade/dao/Upgrade41510to41520.java | 66 +++++++++++++++++++ .../db/schema-41510to41520-cleanup.sql | 21 ++++++ .../META-INF/db/schema-41510to41520.sql | 21 ++++++ 4 files changed, 110 insertions(+) create mode 100644 engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41510to41520.java create mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41510to41520-cleanup.sql create mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41510to41520.sql diff --git a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java index 8c719a31c62..5cc1be8afa6 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -29,6 +29,7 @@ import java.util.Date; import javax.inject.Inject; +import com.cloud.upgrade.dao.Upgrade41510to41520; import org.apache.cloudstack.utils.CloudStackVersion; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -197,6 +198,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { .next("4.14.0.0", new Upgrade41400to41500()) .next("4.14.1.0", new Upgrade41400to41500()) .next("4.15.0.0", new Upgrade41500to41510()) + .next("4.15.1.0", new Upgrade41510to41520()) .build(); } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41510to41520.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41510to41520.java new file mode 100644 index 00000000000..8416651ca87 --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41510to41520.java @@ -0,0 +1,66 @@ +// 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; + +import com.cloud.utils.exception.CloudRuntimeException; + +import java.io.InputStream; +import java.sql.Connection; + +public class Upgrade41510to41520 implements DbUpgrade { + + @Override + public String[] getUpgradableVersionRange() { + return new String[]{"4.15.1.0", "4.15.2.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.15.2.0"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-41510to41520.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } + + @Override + public void performDataMigration(Connection conn) { + } + + @Override + public InputStream[] getCleanupScripts() { + final String scriptFile = "META-INF/db/schema-41510to41520-cleanup.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } +} diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41510to41520-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41510to41520-cleanup.sql new file mode 100644 index 00000000000..e36ac308d59 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41510to41520-cleanup.sql @@ -0,0 +1,21 @@ +-- 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.15.1.0 to 4.15.2.0 +--; + diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41510to41520.sql b/engine/schema/src/main/resources/META-INF/db/schema-41510to41520.sql new file mode 100644 index 00000000000..d0a08c16f78 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41510to41520.sql @@ -0,0 +1,21 @@ +-- 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.15.1.0 to 4.15.2.0 +--; +