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 e5b2df77ccf..d918373a759 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -81,6 +81,7 @@ import com.cloud.upgrade.dao.Upgrade41700to41710; import com.cloud.upgrade.dao.Upgrade41710to41720; import com.cloud.upgrade.dao.Upgrade41720to41800; import com.cloud.upgrade.dao.Upgrade41800to41810; +import com.cloud.upgrade.dao.Upgrade41811to41812; import com.cloud.upgrade.dao.Upgrade420to421; import com.cloud.upgrade.dao.Upgrade421to430; import com.cloud.upgrade.dao.Upgrade430to440; @@ -218,6 +219,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { .next("4.17.1.0", new Upgrade41710to41720()) .next("4.17.2.0", new Upgrade41720to41800()) .next("4.18.0.0", new Upgrade41800to41810()) + .next("4.18.1.0", new Upgrade41811to41812()) .build(); } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41811to41812.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41811to41812.java new file mode 100644 index 00000000000..23af4bbcf52 --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41811to41812.java @@ -0,0 +1,69 @@ +// 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 org.apache.log4j.Logger; + +import java.io.InputStream; +import java.sql.Connection; + +public class Upgrade41811to41812 implements DbUpgrade { + final static Logger LOG = Logger.getLogger(Upgrade41811to41812.class); + + @Override + public String[] getUpgradableVersionRange() { + return new String[]{"4.18.1.1", "4.18.1.2"}; + } + + @Override + public String getUpgradedVersion() { + return "4.18.1.2"; + } + + @Override + public boolean supportsRollingUpgrade() { + return true; + } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-41811to41812.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-41811to41812-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-41811to41812-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41811to41812-cleanup.sql new file mode 100644 index 00000000000..01d5cef1e5e --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41811to41812-cleanup.sql @@ -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 to 4.18.1.2 +--; \ No newline at end of file diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41811to41812.sql b/engine/schema/src/main/resources/META-INF/db/schema-41811to41812.sql new file mode 100644 index 00000000000..5a72bd42153 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41811to41812.sql @@ -0,0 +1,50 @@ +-- 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.18.1.2 +--; + +-- Add property to enable/disable on-demand connection Host to PowerFlex storage pool +INSERT IGNORE INTO `cloud`.`configuration` ( + `category`, + `instance`, + `component`, + `scope`, + `name`, + `value`, + `default_value`, + `is_dynamic`, + `display_text`, + `description` +) VALUES ( + 'Storage', + 'DEFAULT', + 'StorageManager', + 'Global', + 'powerflex.connect.on.demand', + 'false', + 'false', + 1, + 'Connect PowerFlex client on Host on-demand', + 'Connect PowerFlex client on Host when first Volume created and disconnect when last Volume deleted (or always stay connected otherwise).' +); + +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.resource_reservation', 'mgmt_server_id', 'bigint unsigned NULL COMMENT "management server id" '); +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.resource_reservation', 'created', 'datetime DEFAULT NULL COMMENT "date when the reservation was created" '); + +UPDATE `cloud`.`resource_reservation` SET `created` = now() WHERE `created` IS NULL;