Skip to content

Commit deadf81

Browse files
committed
Bug 13423: Drop i_op_vm_ruleset_log__instance_id, u_op_vm_ruleset_log__instance_id key (if exists) and re-add u_op_vm_ruleset_log__instance_id again.
Reviewed-By: Kishan
1 parent 847dde7 commit deadf81

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,37 @@ private void fixIndexes(Connection conn) {
102102
} catch (SQLException e) {
103103
throw new CloudRuntimeException("Unable to update primary key for netapp_volume", e);
104104
}
105+
106+
107+
//Drop i_snapshots__removed key (if exists) and re-add it again
108+
keys = new ArrayList<String>();
109+
keys.add("i_snapshots__removed");
110+
DbUpgradeUtils.dropKeysIfExist(conn, "cloud.snapshots", keys, false);
111+
try {
112+
PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`snapshots` ADD INDEX `i_snapshots__removed`(`removed`)");
113+
pstmt.executeUpdate();
114+
pstmt.close();
115+
} catch (SQLException e) {
116+
throw new CloudRuntimeException("Unable to insert index for removed column in snapshots", e);
117+
}
118+
//Drop i_op_vm_ruleset_log__instance_id, u_op_vm_ruleset_log__instance_id key (if exists) and re-add u_op_vm_ruleset_log__instance_id again
119+
keys = new ArrayList<String>();
120+
keys.add("i_op_vm_ruleset_log__instance_id");
121+
DbUpgradeUtils.dropKeysIfExist(conn, "cloud.op_vm_ruleset_log", keys, false);
122+
123+
keys = new ArrayList<String>();
124+
keys.add("u_op_vm_ruleset_log__instance_id");
125+
DbUpgradeUtils.dropKeysIfExist(conn, "cloud.op_vm_ruleset_log", keys, false);
126+
try {
127+
PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`op_vm_ruleset_log` ADD CONSTRAINT `u_op_vm_ruleset_log__instance_id` UNIQUE (`instance_id`)");
128+
pstmt.executeUpdate();
129+
pstmt.close();
130+
} catch (SQLException e) {
131+
throw new CloudRuntimeException("Unable to execute changes for op_vm_ruleset_log", e);
132+
}
133+
134+
135+
136+
105137
}
106138
}

‎setup/db/db/schema-2213to2214.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
--;
1919

2020
ALTER TABLE `cloud`.`vm_template` MODIFY `extractable` int(1) unsigned NOT NULL default 0 COMMENT 'Is this template extractable';
21-
INSERT INTO configuration (category, instance, component, name, value, description) VALUES ('Advanced', 'DEFAULT', 'management-server', 'external.network.stats.interval', '300', 'Interval (in seconds) to report external network statistics.');
21+
INSERT IGNORE INTO `cloud`.`configuration` (category, instance, component, name, value, description) VALUES ('Advanced', 'DEFAULT', 'management-server', 'external.network.stats.interval', '300', 'Interval (in seconds) to report external network statistics.');
2222

2323
CREATE TABLE `cloud`.`mshost_peer` (
2424
`id` bigint unsigned NOT NULL auto_increment,

0 commit comments

Comments
 (0)