bug 8712: since we add multiple concurrent policy back in 2.2.3, we only support upgrade from 2.1.7 to 2.2.3, otherwise some policies will be removed silently

need test this upgarde
This commit is contained in:
anthony 2011-03-08 17:07:30 -08:00
parent 5b1a421e62
commit b32e8f23a6
4 changed files with 77 additions and 8 deletions

View File

@ -0,0 +1,65 @@
/**
* 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 java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.exception.CloudRuntimeException;
public class UpgradeSnapshot217to223 implements DbUpgrade {
@Override
public File[] getPrepareScripts() {
File file = PropertiesUtil.findConfigFile("schema-snapshot-217to223.sql");
if (file == null) {
throw new CloudRuntimeException("Unable to find the upgrade script, chema-snapshot-217to223.sql");
}
return new File[] {file};
}
@Override
public void performDataMigration(Connection conn) {
}
@Override
public File[] getCleanupScripts() {
return null;
}
@Override
public String[] getUpgradableVersionRange() {
return new String[] { "2.1.7", "2.1.7" };
}
@Override
public String getUpgradedVersion() {
return "2.2.3";
}
@Override
public boolean supportsRollingUpgrade() {
return false;
}
}

View File

@ -64,7 +64,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
protected VersionDaoImpl() {
super();
_upgradeMap.put(new Pair<String, String>("2.1.7", "2.2.1"), new DbUpgrade[] { new Upgrade217to22() });
_upgradeMap.put(new Pair<String, String>("2.1.7", "2.2.3"), new DbUpgrade[] { new Upgrade217to22(), new Upgrade221to222(), new UpgradeSnapshot217to223()});
CurrentVersionSearch = createSearchBuilder(String.class);
CurrentVersionSearch.select(null, Func.FIRST, CurrentVersionSearch.entity().getVersion());

View File

@ -1258,13 +1258,6 @@ CREATE TABLE `cloud`.`snapshot_policy` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`snapshot_policy_ref` (
`snap_id` bigint unsigned NOT NULL,
`volume_id` bigint unsigned NOT NULL,
`policy_id` bigint unsigned NOT NULL,
UNIQUE (snap_id, policy_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`snapshot_schedule` (
`id` bigint unsigned NOT NULL auto_increment,
`volume_id` bigint unsigned NOT NULL COMMENT 'The volume for which this snapshot is being taken',

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.1';
ALTER table snapshots add column `hypervisor_type` varchar(32) DEFAULT 'XenServer';
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.type=snapshot_type=sp.interval+3. WHERE s.id=spr.snap_id and spr.policy_id=sr.id
DROP table snapshot_policy_ref