propagated bb04d0184ea2d713cf211618b53c56c33dbefb87

This commit is contained in:
Alex Huang 2011-05-16 16:35:20 -07:00
parent a7095ef360
commit a6b2d67b98
3 changed files with 28 additions and 9 deletions

View File

@ -66,9 +66,9 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
_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() });
_upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new UpgradeSnapshot223to224(), new Upgrade222to224()});
_upgradeMap.put("2.2.2", new DbUpgrade[] { new Upgrade222to224(), new UpgradeSnapshot223to224() });
_upgradeMap.put("2.2.3", new DbUpgrade[] { new Upgrade222to224(), new UpgradeSnapshot223to224() });
}
protected void runScript(File file) {
@ -122,7 +122,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
for (DbUpgrade upgrade : upgrades) {
s_logger.info("Running upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + upgrade.getUpgradableVersionRange()[1]
+ " to " + upgrade.getUpgradedVersion());
+ " to " + upgrade.getUpgradedVersion());
Transaction txn = Transaction.open("Upgrade");
txn.start();
try {

View File

@ -102,10 +102,19 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
pstmt.close();
}
} else {
rs.close();
pstmt.close();
s_logger.debug("No version table but has nics table, returning 2.2.1");
return "2.2.1";
try {
rs.close();
pstmt.close();
pstmt = conn.prepareStatement("SELECT is_static_nat from firewall_rules");
pstmt.executeQuery();
return "2.2.1";
} catch (SQLException e) {
s_logger.debug("Assuming the exception means static_nat field doesn't exist in firewall_rules table, returning version 2.2.2");
return "2.2.2";
} finally {
rs.close();
pstmt.close();
}
}
}
@ -136,7 +145,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
pstmt = conn.prepareStatement("SELECT is_static_nat from firewall_rules");
pstmt.executeQuery();
throw new CloudRuntimeException(
"Unable to determine the current version, version table exists and empty, nics table doesn't exist, is_static_nat field exists in firewall_rules table");
"Unable to determine the current version, version table exists and empty, nics table doesn't exist, is_static_nat field exists in firewall_rules table");
}
} catch (SQLException e) {
s_logger.debug("Assuming the exception means static_nat field doesn't exist in firewall_rules table, returning version 2.2.2");

View File

@ -1,6 +1,16 @@
--;
-- Schema upgrade from 2.2.2 to 2.2.4;
--;
CREATE TABLE IF NOT EXISTS `cloud`.`version` (
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
`version` char(40) NOT NULL UNIQUE COMMENT 'version',
`updated` datetime NOT NULL COMMENT 'Date this version table was updated',
`step` char(32) NOT NULL COMMENT 'Step in the upgrade to this version',
PRIMARY KEY (`id`),
INDEX `i_version__version`(`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`op_host_capacity` ADD COLUMN `cluster_id` bigint unsigned AFTER `pod_id`;
ALTER TABLE `cloud`.`op_host_capacity` ADD CONSTRAINT `fk_op_host_capacity__cluster_id` FOREIGN KEY `fk_op_host_capacity__cluster_id` (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`op_host_capacity` ADD INDEX `i_op_host_capacity__cluster_id`(`cluster_id`);