mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7081: db upgrade fixes - a) added description for cloud.volumes.iso_id field b) removed duplicated unique key "id_2" from cloud.storage_pool table
This commit is contained in:
parent
89a326a878
commit
f4d2034755
|
|
@ -19,6 +19,9 @@ package com.cloud.upgrade.dao;
|
|||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -55,6 +58,7 @@ public class Upgrade440to450 implements DbUpgrade {
|
|||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
dropInvalidKeyFromStoragePoolTable(conn);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -67,4 +71,17 @@ public class Upgrade440to450 implements DbUpgrade {
|
|||
|
||||
return new File[] {new File(script)};
|
||||
}
|
||||
|
||||
private void dropInvalidKeyFromStoragePoolTable(Connection conn) {
|
||||
HashMap<String, List<String>> uniqueKeys = new HashMap<String, List<String>>();
|
||||
List<String> keys = new ArrayList<String>();
|
||||
|
||||
keys.add("id_2");
|
||||
uniqueKeys.put("storage_pool", keys);
|
||||
|
||||
s_logger.debug("Droping id_2 key from storage_pool table");
|
||||
for (String tableName : uniqueKeys.keySet()) {
|
||||
DbUpgradeUtils.dropKeysIfExist(conn, tableName, uniqueKeys.get(tableName), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,3 +240,5 @@ ALTER TABLE `cloud`.`user` ADD COLUMN domain_id bigint(20) unsigned DEFAULT NULL
|
|||
ALTER TABLE `cloud`.`user` ADD CONSTRAINT `fk_user__domain_id` FOREIGN KEY `fk_user__domain_id`(`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE;
|
||||
UPDATE `cloud`.`user` SET `cloud`.`user`.domain_id=(SELECT `cloud`.`account`.domain_id FROM `cloud`.`account` WHERE `cloud`.`account`.id=`cloud`.`user`.account_id) where id > 0;
|
||||
ALTER TABLE `cloud`.`user` ADD UNIQUE KEY `username_domain_id` (`username`,`domain_id`);
|
||||
|
||||
ALTER TABLE `cloud`.`volumes` CHANGE COLUMN `iso_id` `iso_id` bigint(20) unsigned COMMENT 'The id of the iso from which the volume was created';
|
||||
|
|
|
|||
Loading…
Reference in New Issue