Skip to content

Commit 685a58a

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-7210: removed duplicated foreign key from async_job_join_map table
1 parent 93c64cd commit 685a58a

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

engine/schema/src/com/cloud/upgrade/dao/Upgrade441to450.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public File[] getPrepareScripts() {
6060
@Override
6161
public void performDataMigration(Connection conn) {
6262
dropInvalidKeyFromStoragePoolTable(conn);
63+
dropDuplicatedForeignKeyFromAsyncJobTable(conn);
6364
}
6465

6566

@@ -80,9 +81,22 @@ private void dropInvalidKeyFromStoragePoolTable(Connection conn) {
8081
keys.add("id_2");
8182
uniqueKeys.put("storage_pool", keys);
8283

83-
s_logger.debug("Droping id_2 key from storage_pool table");
84+
s_logger.debug("Dropping id_2 key from storage_pool table");
8485
for (Map.Entry<String, List<String>> entry: uniqueKeys.entrySet()) {
8586
DbUpgradeUtils.dropKeysIfExist(conn,entry.getKey(), entry.getValue(), false);
8687
}
8788
}
89+
90+
private void dropDuplicatedForeignKeyFromAsyncJobTable(Connection conn) {
91+
HashMap<String, List<String>> foreignKeys = new HashMap<String, List<String>>();
92+
List<String> keys = new ArrayList<String>();
93+
94+
keys.add("fk_async_job_join_map__join_job_id");
95+
foreignKeys.put("async_job_join_map", keys);
96+
97+
s_logger.debug("Dropping fk_async_job_join_map__join_job_id key from async_job_join_map table");
98+
for (Map.Entry<String, List<String>> entry: foreignKeys.entrySet()) {
99+
DbUpgradeUtils.dropKeysIfExist(conn,entry.getKey(), entry.getValue(), true);
100+
}
101+
}
88102
}

0 commit comments

Comments
 (0)