From 671a70a9a5f2de0cccb81b6af6c7b27fa03dd536 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 27 Mar 2019 00:00:47 +0530 Subject: [PATCH] schema: add empty DB upgrade path from 4.12.0.0 to 4.13.0.0 (#3236) This adds empty empty upgrade path from 4.12.0.0 to 4.13.0.0. Signed-off-by: Rohit Yadav --- .../cloud/upgrade/DatabaseUpgradeChecker.java | 2 + .../upgrade/dao/Upgrade41200to41300.java | 72 +++++++++++++++++++ .../db/schema-41200to41300-cleanup.sql | 21 ++++++ .../META-INF/db/schema-41200to41300.sql | 21 ++++++ 4 files changed, 116 insertions(+) create mode 100644 engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41200to41300.java create mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41200to41300-cleanup.sql create mode 100644 engine/schema/src/main/resources/META-INF/db/schema-41200to41300.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 6da40fbf974..fbb1399f190 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -64,6 +64,7 @@ import com.cloud.upgrade.dao.Upgrade410to420; import com.cloud.upgrade.dao.Upgrade41100to41110; import com.cloud.upgrade.dao.Upgrade41110to41120; import com.cloud.upgrade.dao.Upgrade41120to41200; +import com.cloud.upgrade.dao.Upgrade41200to41300; import com.cloud.upgrade.dao.Upgrade420to421; import com.cloud.upgrade.dao.Upgrade421to430; import com.cloud.upgrade.dao.Upgrade430to440; @@ -183,6 +184,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { .next("4.11.0.0", new Upgrade41100to41110()) .next("4.11.1.0", new Upgrade41110to41120()) .next("4.11.2.0", new Upgrade41120to41200()) + .next("4.12.0.0", new Upgrade41200to41300()) .build(); } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41200to41300.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41200to41300.java new file mode 100644 index 00000000000..f7e968c7816 --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41200to41300.java @@ -0,0 +1,72 @@ +// 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 java.io.InputStream; +import java.sql.Connection; + +import org.apache.log4j.Logger; + +import com.cloud.utils.exception.CloudRuntimeException; + +public class Upgrade41200to41300 implements DbUpgrade { + + final static Logger LOG = Logger.getLogger(Upgrade41200to41300.class); + + @Override + public String[] getUpgradableVersionRange() { + return new String[] {"4.12.0.0", "4.13.0.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.13.0.0"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-41200to41300.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-41200to41300-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-41200to41300-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41200to41300-cleanup.sql new file mode 100644 index 00000000000..5702186b1ec --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41200to41300-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.12.0.0 to 4.13.0.0 +--; + diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41200to41300.sql b/engine/schema/src/main/resources/META-INF/db/schema-41200to41300.sql new file mode 100644 index 00000000000..d4de8c4a993 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41200to41300.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.12.0.0 to 4.13.0.0 +--; +