bug 11667: drop primary keys in cloud_usage.usage_load_balancer_policy and cloud_usage.usage_port_forwarding

status 11667: resolved fixed

Conflicts:

	server/src/com/cloud/user/AccountManagerImpl.java
This commit is contained in:
alena 2011-10-07 11:00:55 -07:00
parent d399c901c8
commit eba6864965
5 changed files with 25 additions and 6 deletions

View File

@ -390,7 +390,7 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{
if (domainId != null) { if (domainId != null) {
sc.setParameters("domainId", domainId); sc.setParameters("domainId", domainId);
sc.setParameters("accountId", null); sc.setParameters("accountId", (Object[])null);
} }
if (resourceType != null) { if (resourceType != null) {

View File

@ -39,6 +39,25 @@ public class DbUpgradeUtils {
} }
public static void dropPrimaryKeyIfExists(Connection conn, String tableName) {
PreparedStatement pstmt = null;
try {
pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP PRIMARY KEY ");
pstmt.executeUpdate();
s_logger.debug("Primary key is dropped successfully from the table " + tableName);
} catch (SQLException e) {
// do nothing here
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
}
public static void dropTableColumnsIfExist(Connection conn, String tableName, List<String> columns) { public static void dropTableColumnsIfExist(Connection conn, String tableName, List<String> columns) {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try { try {

View File

@ -89,5 +89,8 @@ public class Upgrade2212to2213 implements DbUpgrade {
} }
// drop primary keys
DbUpgradeUtils.dropPrimaryKeyIfExists(conn, "cloud_usage.usage_load_balancer_policy");
DbUpgradeUtils.dropPrimaryKeyIfExists(conn, "cloud_usage.usage_port_forwarding");
} }
} }

View File

@ -244,7 +244,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
return true; return true;
} }
public AccountVO getSystemAccount() { public AccountVO getSystemAccount() {
if (_systemAccount == null) { if (_systemAccount == null) {
_systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM); _systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);

View File

@ -178,8 +178,7 @@ CREATE TABLE `cloud_usage`.`usage_load_balancer_policy` (
`account_id` bigint unsigned NOT NULL, `account_id` bigint unsigned NOT NULL,
`domain_id` bigint unsigned NOT NULL, `domain_id` bigint unsigned NOT NULL,
`created` DATETIME NOT NULL, `created` DATETIME NOT NULL,
`deleted` DATETIME NULL, `deleted` DATETIME NULL
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud_usage`.`usage_load_balancer_policy` ADD INDEX `i_usage_load_balancer_policy__account_id`(`account_id`); ALTER TABLE `cloud_usage`.`usage_load_balancer_policy` ADD INDEX `i_usage_load_balancer_policy__account_id`(`account_id`);
@ -210,8 +209,7 @@ CREATE TABLE `cloud_usage`.`usage_port_forwarding` (
`account_id` bigint unsigned NOT NULL, `account_id` bigint unsigned NOT NULL,
`domain_id` bigint unsigned NOT NULL, `domain_id` bigint unsigned NOT NULL,
`created` DATETIME NOT NULL, `created` DATETIME NOT NULL,
`deleted` DATETIME NULL, `deleted` DATETIME NULL
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud_usage`.`usage_port_forwarding` ADD INDEX `i_usage_port_forwarding__account_id`(`account_id`); ALTER TABLE `cloud_usage`.`usage_port_forwarding` ADD INDEX `i_usage_port_forwarding__account_id`(`account_id`);