From f890c492721c1d58db2dfee73bb8bdda41af20b9 Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 27 Apr 2011 15:42:05 -0700 Subject: [PATCH] bug 9617: fixed snapshot upgrade from 223 to 224 status 9617: resolved fixed --- .../cloud/upgrade/DatabaseUpgradeChecker.java | 15 ++--- ...o223.java => UpgradeSnapshot217to224.java} | 8 +-- .../upgrade/dao/UpgradeSnapshot223to224.java | 61 +++++++++++++++++++ ...to223.sql => schema-snapshot-217to224.sql} | 0 setup/db/db/schema-snapshot-223to224.sql | 11 ++++ 5 files changed, 84 insertions(+), 11 deletions(-) rename server/src/com/cloud/upgrade/dao/{UpgradeSnapshot217to223.java => UpgradeSnapshot217to224.java} (91%) create mode 100644 server/src/com/cloud/upgrade/dao/UpgradeSnapshot223to224.java rename setup/db/db/{schema-snapshot-217to223.sql => schema-snapshot-217to224.sql} (100%) create mode 100644 setup/db/db/schema-snapshot-223to224.sql diff --git a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java index c22e8919e2f..4bf11cc198c 100644 --- a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -38,7 +38,8 @@ import com.cloud.upgrade.dao.Upgrade218to22; import com.cloud.upgrade.dao.Upgrade218to224DomainVlans; import com.cloud.upgrade.dao.Upgrade221to222; import com.cloud.upgrade.dao.Upgrade222to224; -import com.cloud.upgrade.dao.UpgradeSnapshot217to223; +import com.cloud.upgrade.dao.UpgradeSnapshot217to224; +import com.cloud.upgrade.dao.UpgradeSnapshot223to224; import com.cloud.upgrade.dao.VersionDao; import com.cloud.upgrade.dao.VersionDaoImpl; import com.cloud.upgrade.dao.VersionVO; @@ -59,12 +60,12 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { public DatabaseUpgradeChecker() { _dao = ComponentLocator.inject(VersionDaoImpl.class); - _upgradeMap.put("2.1.7", new DbUpgrade[] { new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224() }); - _upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224(), new Upgrade218to224DomainVlans() }); - _upgradeMap.put("2.1.9", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224(), new Upgrade218to224DomainVlans() }); - _upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new Upgrade222to224()}); - _upgradeMap.put("2.2.2", new DbUpgrade[] { new Upgrade222to224() }); - _upgradeMap.put("2.2.3", new DbUpgrade[] { new Upgrade222to224() }); + _upgradeMap.put("2.1.7", new DbUpgrade[] { new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(), new Upgrade222to224() }); + _upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade218to224DomainVlans() }); + _upgradeMap.put("2.1.9", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade218to224DomainVlans() }); + _upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new UpgradeSnapshot223to224(), new Upgrade222to224()}); + _upgradeMap.put("2.2.2", new DbUpgrade[] { new UpgradeSnapshot223to224(), new Upgrade222to224() }); + _upgradeMap.put("2.2.3", new DbUpgrade[] { new UpgradeSnapshot223to224(), new Upgrade222to224() }); } protected void runScript(File file) { diff --git a/server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to223.java b/server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to224.java similarity index 91% rename from server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to223.java rename to server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to224.java index 408d18eceba..21cf61de258 100644 --- a/server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to223.java +++ b/server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to224.java @@ -23,13 +23,13 @@ import java.sql.Connection; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class UpgradeSnapshot217to223 implements DbUpgrade { +public class UpgradeSnapshot217to224 implements DbUpgrade { @Override public File[] getPrepareScripts() { - String file = Script.findScript("", "db/schema-snapshot-217to223.sql"); + String file = Script.findScript("", "db/schema-snapshot-217to224.sql"); if (file == null) { - throw new CloudRuntimeException("Unable to find the upgrade script, chema-snapshot-217to223.sql"); + throw new CloudRuntimeException("Unable to find the upgrade script, schema-snapshot-217to224.sql"); } return new File[] { new File(file)}; @@ -51,7 +51,7 @@ public class UpgradeSnapshot217to223 implements DbUpgrade { @Override public String getUpgradedVersion() { - return "2.2.3"; + return "2.2.4"; } @Override diff --git a/server/src/com/cloud/upgrade/dao/UpgradeSnapshot223to224.java b/server/src/com/cloud/upgrade/dao/UpgradeSnapshot223to224.java new file mode 100644 index 00000000000..565fbac8d67 --- /dev/null +++ b/server/src/com/cloud/upgrade/dao/UpgradeSnapshot223to224.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.upgrade.dao; + +import java.io.File; +import java.sql.Connection; + +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + +public class UpgradeSnapshot223to224 implements DbUpgrade { + + @Override + public File[] getPrepareScripts() { + String file = Script.findScript("", "db/schema-snapshot-223to224.sql"); + if (file == null) { + throw new CloudRuntimeException("Unable to find the upgrade script, schema-snapshot-223to224.sql"); + } + + return new File[] { new File(file)}; + } + + @Override + public void performDataMigration(Connection conn) { + } + + @Override + public File[] getCleanupScripts() { + return null; + } + + @Override + public String[] getUpgradableVersionRange() { + return new String[] { "2.2.3", "2.2.3" }; + } + + @Override + public String getUpgradedVersion() { + return "2.2.4"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } +} diff --git a/setup/db/db/schema-snapshot-217to223.sql b/setup/db/db/schema-snapshot-217to224.sql similarity index 100% rename from setup/db/db/schema-snapshot-217to223.sql rename to setup/db/db/schema-snapshot-217to224.sql diff --git a/setup/db/db/schema-snapshot-223to224.sql b/setup/db/db/schema-snapshot-223to224.sql new file mode 100644 index 00000000000..aaf12e7fbea --- /dev/null +++ b/setup/db/db/schema-snapshot-223to224.sql @@ -0,0 +1,11 @@ +ALTER table snapshots add column `data_center_id` bigint unsigned NOT NULL ; +ALTER table snapshots add column `domain_id` bigint unsigned NOT NULL; +ALTER table snapshots add column `disk_offering_id` bigint unsigned NOT NULL; +ALTER table snapshots add column `size` bigint unsigned NOT NULL; +ALTER table snapshots add column `version` varchar(32) DEFAULT '2.2'; + +DELETE FROM snapshot_policy where id=1; +UPDATE snapshots s, volumes v SET s.data_center_id=v.data_center_id, s.domain_id=v.domain_id, s.disk_offering_id=v.disk_offering_id, s.size=v.size WHERE s.volume_id = v.id; +UPDATE snapshots s, snapshot_policy sp, snapshot_policy_ref spr SET s.snapshot_type=sp.interval+3 WHERE s.id=spr.snap_id and spr.policy_id=sp.id; + +DROP table snapshot_policy_ref;