CLOUDSTACK-3612: fixed missing indexes in some cloud tables. In the bug those tables are addressed as table #4, table #5, and table #6

Conflicts:
	setup/db/db/schema-410to420.sql
This commit is contained in:
Alena Prokharchyk 2013-07-18 15:12:40 -07:00
parent 226bed7ec8
commit ca1f8a6632
2 changed files with 57 additions and 0 deletions

View File

@ -98,6 +98,8 @@ public class Upgrade410to420 implements DbUpgrade {
migrateVolumeHostRef(conn);
migrateTemplateHostRef(conn);
migrateSnapshotStoreRef(conn);
fixNiciraKeys(conn);
fixRouterKeys(conn);
}
private void fixBaremetalForeignKeys(Connection conn) {
@ -1846,4 +1848,54 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
private void fixNiciraKeys(Connection conn) {
//First drop the key if it exists.
List<String> keys = new ArrayList<String>();
s_logger.debug("Dropping foreign key fk_nicira_nvp_nic_map__nic from the table nicira_nvp_nic_map if it exists");
keys.add("fk_nicira_nvp_nic_map__nic");
DbUpgradeUtils.dropKeysIfExist(conn, "nicira_nvp_nic_map", keys, true);
//Now add foreign key.
PreparedStatement pstmt = null;
try {
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`nicira_nvp_nic_map` ADD CONSTRAINT `fk_nicira_nvp_nic_map__nic` FOREIGN KEY (`nic`) REFERENCES `nics` (`uuid`) ON DELETE CASCADE");
pstmt.executeUpdate();
s_logger.debug("Added foreign key fk_nicira_nvp_nic_map__nic to the table nicira_nvp_nic_map");
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to add foreign key fk_nicira_nvp_nic_map__nic to the table nicira_nvp_nic_map", e);
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
}
private void fixRouterKeys(Connection conn) {
//First drop the key if it exists.
List<String> keys = new ArrayList<String>();
s_logger.debug("Dropping foreign key fk_router_network_ref__router_id from the table router_network_ref if it exists");
keys.add("fk_router_network_ref__router_id");
DbUpgradeUtils.dropKeysIfExist(conn, "router_network_ref", keys, true);
//Now add foreign key.
PreparedStatement pstmt = null;
try {
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`router_network_ref` ADD CONSTRAINT `fk_router_network_ref__router_id` FOREIGN KEY (`router_id`) REFERENCES `domain_router` (`id`) ON DELETE CASCADE");
pstmt.executeUpdate();
s_logger.debug("Added foreign key fk_router_network_ref__router_id to the table router_network_ref");
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to add foreign key fk_router_network_ref__router_id to the table router_network_ref", e);
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
}
}

View File

@ -2240,6 +2240,11 @@ CREATE VIEW `cloud`.`project_view` AS
and resource_tags.resource_type = 'Project'
left join
`cloud`.`project_account` pacct ON projects.id = pacct.project_id;
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'network.loadbalancer.haproxy.max.conn', '4096', 'Load Balancer(haproxy) maximum number of concurrent connections(global max)');
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `concurrent_connections` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)';
ALTER TABLE `cloud`.`sync_queue` MODIFY `queue_size` smallint(6) NOT NULL DEFAULT '0' COMMENT 'number of items being processed by the queue';
ALTER TABLE `cloud`.`sync_queue` MODIFY `queue_size_limit` smallint(6) NOT NULL DEFAULT '1' COMMENT 'max number of items the queue can process concurrently';