Skip to content

Commit 9fd0655

Browse files
nitinmehDaanHoogland
authored andcommitted
CLOUDSTACK-6599: Add the column in Java upgrade path since 4.2 already has the extract template/volume columns
Conflicts: engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java
1 parent 9286417 commit 9fd0655

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,39 @@ public File[] getPrepareScripts() {
6262
public void performDataMigration(Connection conn) {
6363
secondaryIpsAccountAndDomainIdsUpdate(conn);
6464
moveCidrsToTheirOwnTable(conn);
65+
addExtractTemplateAndVolumeColumns(conn);
6566
updateVlanUris(conn);
6667
}
6768

69+
private void addExtractTemplateAndVolumeColumns(Connection conn) {
70+
PreparedStatement pstmt = null;
71+
ResultSet rs = null;
72+
73+
try {
74+
75+
// Add download_url_created, download_url to template_store_ref
76+
pstmt = conn.prepareStatement("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'cloud' AND TABLE_NAME = 'template_store_ref' AND COLUMN_NAME = 'download_url_created'");
77+
rs = pstmt.executeQuery();
78+
if (!rs.next()) {
79+
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`template_store_ref` ADD COLUMN `download_url_created` datetime");
80+
pstmt.executeUpdate();
81+
82+
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`template_store_ref` ADD COLUMN `download_url` varchar(255)");
83+
pstmt.executeUpdate();
84+
}
85+
86+
// Add download_url_created to volume_store_ref - note download_url already exists
87+
pstmt = conn.prepareStatement("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'cloud' AND TABLE_NAME = 'volume_store_ref' AND COLUMN_NAME = 'download_url_created'");
88+
rs = pstmt.executeQuery();
89+
if (!rs.next()) {
90+
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`volume_store_ref` ADD COLUMN `download_url_created` datetime");
91+
pstmt.executeUpdate();
92+
}
93+
94+
} catch (SQLException e) {
95+
throw new CloudRuntimeException("Adding columns for Extract Template And Volume functionality failed");
96+
}
97+
}
6898

6999
private void secondaryIpsAccountAndDomainIdsUpdate(Connection conn) {
70100
PreparedStatement pstmt = null;

‎setup/db/db/schema-430to440.sql‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,3 @@ alter table `cloud`.`vlan` add column created datetime NULL COMMENT 'date create
17051705
alter table `cloud`.`user_ip_address` drop key public_ip_address;
17061706
alter table `cloud`.`user_ip_address` add UNIQUE KEY public_ip_address (public_ip_address,source_network_id, removed);
17071707

1708-
ALTER TABLE `cloud`.`volume_store_ref` ADD `download_url_created` datetime;
1709-
ALTER TABLE `cloud`.`template_store_ref` ADD `download_url_created` datetime;
1710-
ALTER TABLE `cloud`.`template_store_ref` ADD `download_url` varchar(255);
1711-

0 commit comments

Comments
 (0)