This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.22 by this push:
     new e33f4754f53 Fix DB upgrade script for 4.22 (#12111)
e33f4754f53 is described below

commit e33f4754f533008a5fc252d8bb612a571eb6d021
Author: Abhisar Sinha <[email protected]>
AuthorDate: Wed Nov 26 13:55:41 2025 +0530

    Fix DB upgrade script for 4.22 (#12111)
---
 .../com/cloud/upgrade/DatabaseUpgradeChecker.java  |  2 ++
 .../com/cloud/upgrade/dao/Upgrade42200to42210.java | 30 ++++++++++++++++++++++
 .../resources/META-INF/db/schema-42100to42200.sql  |  7 -----
 .../META-INF/db/schema-42200to42210-cleanup.sql    | 20 +++++++++++++++
 .../resources/META-INF/db/schema-42200to42210.sql  | 27 +++++++++++++++++++
 5 files changed, 79 insertions(+), 7 deletions(-)

diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java 
b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
index c211b3e9728..bf660f37bc3 100644
--- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
@@ -91,6 +91,7 @@ import com.cloud.upgrade.dao.Upgrade41910to42000;
 import com.cloud.upgrade.dao.Upgrade42000to42010;
 import com.cloud.upgrade.dao.Upgrade42010to42100;
 import com.cloud.upgrade.dao.Upgrade42100to42200;
+import com.cloud.upgrade.dao.Upgrade42200to42210;
 import com.cloud.upgrade.dao.Upgrade420to421;
 import com.cloud.upgrade.dao.Upgrade421to430;
 import com.cloud.upgrade.dao.Upgrade430to440;
@@ -236,6 +237,7 @@ public class DatabaseUpgradeChecker implements 
SystemIntegrityChecker {
                 .next("4.20.0.0", new Upgrade42000to42010())
                 .next("4.20.1.0", new Upgrade42010to42100())
                 .next("4.21.0.0", new Upgrade42100to42200())
+                .next("4.22.0.0", new Upgrade42200to42210())
                 .build();
     }
 
diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java 
b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java
new file mode 100644
index 00000000000..c9610f7b9ff
--- /dev/null
+++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java
@@ -0,0 +1,30 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.upgrade.dao;
+
+public class Upgrade42200to42210 extends DbUpgradeAbstractImpl implements 
DbUpgrade, DbUpgradeSystemVmTemplate {
+
+    @Override
+    public String[] getUpgradableVersionRange() {
+        return new String[] {"4.22.0.0", "4.22.1.0"};
+    }
+
+    @Override
+    public String getUpgradedVersion() {
+        return "4.22.1.0";
+    }
+}
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql
index ecca3482d59..b523016aa3d 100644
--- a/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql
+++ b/engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql
@@ -41,13 +41,6 @@ CALL 
`cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.ldap_configuration', 'uuid', 'VARCHA
 -- Populate uuid for existing rows where uuid is NULL or empty
 UPDATE `cloud`.`ldap_configuration` SET uuid = UUID() WHERE uuid IS NULL OR 
uuid = '';
 
--- Add vm_id column to usage_event table for volume usage events
-CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.usage_event','vm_id', 'bigint 
UNSIGNED NULL COMMENT "VM ID associated with volume usage events"');
-CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_event','vm_id', 
'bigint UNSIGNED NULL COMMENT "VM ID associated with volume usage events"');
-
--- Add vm_id column to cloud_usage.usage_volume table
-CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_volume','vm_id', 
'bigint UNSIGNED NULL COMMENT "VM ID associated with the volume usage"');
-
 -- Add the column cross_zone_instance_creation to cloud.backup_repository. if 
enabled it means that new Instance can be created on all Zones from Backups on 
this Repository.
 CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_repository', 
'cross_zone_instance_creation', 'TINYINT(1) DEFAULT NULL COMMENT ''Backup 
Repository can be used for disaster recovery on another zone''');
 
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql
new file mode 100644
index 00000000000..54baf226ac4
--- /dev/null
+++ 
b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql
@@ -0,0 +1,20 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema upgrade cleanup from 4.22.0.0 to 4.22.1.0
+--;
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql
new file mode 100644
index 00000000000..6aafa7ba81e
--- /dev/null
+++ b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql
@@ -0,0 +1,27 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema upgrade from 4.22.0.0 to 4.22.1.0
+--;
+
+-- Add vm_id column to usage_event table for volume usage events
+CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.usage_event','vm_id', 'bigint 
UNSIGNED NULL COMMENT "VM ID associated with volume usage events"');
+CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_event','vm_id', 
'bigint UNSIGNED NULL COMMENT "VM ID associated with volume usage events"');
+
+-- Add vm_id column to cloud_usage.usage_volume table
+CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_volume','vm_id', 
'bigint UNSIGNED NULL COMMENT "VM ID associated with the volume usage"');

Reply via email to