Github user jburwell commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/768#discussion_r42445486
--- Diff: engine/schema/src/com/cloud/upgrade/dao/Upgrade452to460.java ---
@@ -60,10 +60,25 @@ public boolean supportsRollingUpgrade() {
@Override
public void performDataMigration(final Connection conn) {
+ alterAddColumnToCloudUsage(conn);
updateVMInstanceUserId(conn);
addIndexForVMInstance(conn);
}
+ public void alterAddColumnToCloudUsage(final Connection conn) {
+ final String alterTableSql = "ALTER TABLE
`cloud_usage`.`cloud_usage` ADD COLUMN `quota_calculated` tinyint(1) DEFAULT 0
NOT NULL COMMENT 'quota calculation status'";
+ try (PreparedStatement pstmt =
conn.prepareStatement(alterTableSql)) {
+ pstmt.executeUpdate();
+ s_logger.info("Altered usage table and added column
quota_calculated");
+ } catch (SQLException e) {
+ if (e.getMessage().contains("quota_calculated")) {
--- End diff --
Checking the string contents seems brittle. Is there an error code that
can be checked from this condition via ``SQLException.getErrorCode()``?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---