mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Fixed bunch of DB upgrade bugs related with the fact that DB was manually upated in 2.1.x setup (some records were deleted from the DB)
This commit is contained in:
parent
b1c3c8c1d9
commit
fbdb663970
@ -1314,7 +1314,15 @@ public class Upgrade218to22 implements DbUpgrade {
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
if (!rs.next()) {
|
||||
s_logger.warn("Unable to find public IP address " + publicIp + "; skipping lb rule id=" + originalLbId + " from update");
|
||||
s_logger.warn("Unable to find public IP address " + publicIp + "; skipping lb rule id=" + originalLbId + " from update. Cleaning it up from load_balancer_vm_map and load_balancer table");
|
||||
pstmt = conn.prepareStatement("DELETE from load_balancer_vm_map where load_balancer_id=?");
|
||||
pstmt.setLong(1, originalLbId);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE from load_balancer where id=?");
|
||||
pstmt.setLong(1, originalLbId);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,6 @@ ALTER TABLE `cloud`.`user_ip_address` ADD UNIQUE (`public_ip_address`, `source_n
|
||||
ALTER TABLE `cloud`.`user_ip_address` ADD CONSTRAINT `fk_user_ip_address__source_network_id` FOREIGN KEY (`source_network_id`) REFERENCES `networks`(`id`);
|
||||
ALTER TABLE `cloud`.`user_ip_address` ADD CONSTRAINT `fk_user_ip_address__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`);
|
||||
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__account_id` FOREIGN KEY `fk_vm_instance__account_id` (`account_id`) REFERENCES `account` (`id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__service_offering_id` FOREIGN KEY `fk_vm_instance__service_offering_id` (`service_offering_id`) REFERENCES `service_offering` (`id`);
|
||||
|
||||
ALTER TABLE `cloud`.`template_spool_ref` ADD CONSTRAINT `fk_template_spool_ref__pool_id` FOREIGN KEY (`pool_id`) REFERENCES `storage_pool`(`id`) ON DELETE CASCADE;
|
||||
@ -119,3 +118,10 @@ DELETE FROM op_ha_work WHERE taken IS NOT NULL;
|
||||
DELETE FROM op_ha_work WHERE host_id NOT IN (SELECT DISTINCT id FROM host);
|
||||
ALTER TABLE `cloud`.`op_ha_work` ADD CONSTRAINT `fk_op_ha_work__host_id` FOREIGN KEY `fk_op_ha_work__host_id` (`host_id`) REFERENCES `host` (`id`);
|
||||
|
||||
UPDATE `cloud`.`vm_instance` SET last_host_id=NULL WHERE last_host_id NOT IN (SELECT DISTINCT id FROM host);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__last_host_id` FOREIGN KEY `fk_vm_instance__last_host_id` (`last_host_id`) REFERENCES `host`(`id`);
|
||||
|
||||
UPDATE `cloud`.`vm_instance` SET domain_id=1, account_id=1 where account_id not in (select distinct id from account) or domain_id not in (select distinct id from domain);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__account_id` FOREIGN KEY `fk_vm_instance__account_id` (`account_id`) REFERENCES `account` (`id`);
|
||||
|
||||
|
||||
|
||||
@ -993,6 +993,3 @@ ALTER TABLE `cloud`.`template_host_ref` DROP FOREIGN KEY `fk_template_host_ref__
|
||||
ALTER TABLE `cloud`.`template_host_ref` ADD CONSTRAINT `fk_template_host_ref__template_id` FOREIGN KEY `fk_template_host_ref__template_id` (`template_id`) REFERENCES `vm_template` (`id`);
|
||||
|
||||
ALTER TABLE `cloud`.`user_ip_address` ADD CONSTRAINT `fk_user_ip_address__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__last_host_id` FOREIGN KEY `fk_vm_instance__last_host_id` (`last_host_id`) REFERENCES `host`(`id`);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user