Skip to content

Commit eba6864

Browse files
committed
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
1 parent d399c90 commit eba6864

5 files changed

Lines changed: 25 additions & 6 deletions

File tree

server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ public List<ResourceLimitVO> searchForLimits(Long id, Long accountId, Long domai
390390

391391
if (domainId != null) {
392392
sc.setParameters("domainId", domainId);
393-
sc.setParameters("accountId", null);
393+
sc.setParameters("accountId", (Object[])null);
394394
}
395395

396396
if (resourceType != null) {

server/src/com/cloud/upgrade/dao/DbUpgradeUtils.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ public static void dropKeysIfExist(Connection conn, String tableName, List<Strin
3939
}
4040

4141

42+
public static void dropPrimaryKeyIfExists(Connection conn, String tableName) {
43+
PreparedStatement pstmt = null;
44+
try {
45+
pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP PRIMARY KEY ");
46+
pstmt.executeUpdate();
47+
s_logger.debug("Primary key is dropped successfully from the table " + tableName);
48+
} catch (SQLException e) {
49+
// do nothing here
50+
} finally {
51+
try {
52+
if (pstmt != null) {
53+
pstmt.close();
54+
}
55+
} catch (SQLException e) {
56+
}
57+
}
58+
}
59+
60+
4261
public static void dropTableColumnsIfExist(Connection conn, String tableName, List<String> columns) {
4362
PreparedStatement pstmt = null;
4463
try {

server/src/com/cloud/upgrade/dao/Upgrade2212to2213.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,8 @@ private void fixForeignKeys(Connection conn) {
8989
}
9090

9191

92+
// drop primary keys
93+
DbUpgradeUtils.dropPrimaryKeyIfExists(conn, "cloud_usage.usage_load_balancer_policy");
94+
DbUpgradeUtils.dropPrimaryKeyIfExists(conn, "cloud_usage.usage_port_forwarding");
9295
}
9396
}

server/src/com/cloud/user/AccountManagerImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ public boolean stop() {
244244
return true;
245245
}
246246

247-
248247
public AccountVO getSystemAccount() {
249248
if (_systemAccount == null) {
250249
_systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);

setup/db/create-schema-premium.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ CREATE TABLE `cloud_usage`.`usage_load_balancer_policy` (
178178
`account_id` bigint unsigned NOT NULL,
179179
`domain_id` bigint unsigned NOT NULL,
180180
`created` DATETIME NOT NULL,
181-
`deleted` DATETIME NULL,
182-
PRIMARY KEY (`id`)
181+
`deleted` DATETIME NULL
183182
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
184183

185184
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` (
210209
`account_id` bigint unsigned NOT NULL,
211210
`domain_id` bigint unsigned NOT NULL,
212211
`created` DATETIME NOT NULL,
213-
`deleted` DATETIME NULL,
214-
PRIMARY KEY (`id`)
212+
`deleted` DATETIME NULL
215213
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
216214

217215
ALTER TABLE `cloud_usage`.`usage_port_forwarding` ADD INDEX `i_usage_port_forwarding__account_id`(`account_id`);

0 commit comments

Comments
 (0)