bug 9617: fixed snapshot upgrade from 223 to 224

status 9617: resolved fixed
This commit is contained in:
anthony 2011-04-27 15:42:05 -07:00
parent e8e9bbccfb
commit f890c49272
5 changed files with 84 additions and 11 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
}

View File

@ -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;