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

status 11667: resolved fixed
This commit is contained in:
alena 2011-10-07 10:58:19 -07:00
parent e765ea769f
commit 16989227d9
4 changed files with 25 additions and 5 deletions

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) {
PreparedStatement pstmt = null;
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

@ -489,7 +489,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
if (domainId != null) {
sc.setParameters("domainId", domainId);
sc.setParameters("accountId", null);
sc.setParameters("accountId", (Object[])null);
}
if (resourceType != null) {

View File

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