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

nvazquez 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 0931cf818e6 usage: widen usage_volume unique key to include vm_id 
(#13933)
0931cf818e6 is described below

commit 0931cf818e6b1e620e158a97164bafbc8e31e0c8
Author: David Taylor <[email protected]>
AuthorDate: Fri Oct 9 15:00:22 2026 +0100

    usage: widen usage_volume unique key to include vm_id (#13933)
    
    Backport of #13909 to 4.22, targeting 4.22.2.
    
    This also creates the 4.22.1.0 to 4.22.2.0 upgrade path, which didn't
    exist yet: schema-42210to42220.sql, its cleanup companion, the
    Upgrade42210to42220 class, and the registration in DatabaseUpgradeChecker.
    
    The CALLs can't go into schema-42200to42210.sql instead, because every
    4.22.1.0 install has already run that file and those are the affected
    clusters.
    
    Co-authored-by: Abhisar Sinha <[email protected]>
---
 .../src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java      | 2 ++
 engine/schema/src/main/resources/META-INF/db/schema-42210to42220.sql | 5 +++++
 2 files changed, 7 insertions(+)

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 3868ca960e0..92de79b83ec 100644
--- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
@@ -94,6 +94,7 @@ import com.cloud.upgrade.dao.Upgrade42030to42040;
 import com.cloud.upgrade.dao.Upgrade42040to42100;
 import com.cloud.upgrade.dao.Upgrade42100to42200;
 import com.cloud.upgrade.dao.Upgrade42200to42210;
+import com.cloud.upgrade.dao.Upgrade42210to42220;
 import com.cloud.upgrade.dao.Upgrade420to421;
 import com.cloud.upgrade.dao.Upgrade421to430;
 import com.cloud.upgrade.dao.Upgrade430to440;
@@ -246,6 +247,7 @@ public class DatabaseUpgradeChecker implements 
SystemIntegrityChecker {
                 .next("4.20.4.0", new Upgrade42040to42100())
                 .next("4.21.0.0", new Upgrade42100to42200())
                 .next("4.22.0.0", new Upgrade42200to42210())
+                .next("4.22.1.0", new Upgrade42210to42220())
                 .build();
     }
 
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-42210to42220.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-42210to42220.sql
index f6d73def74f..7fefed18fd7 100644
--- a/engine/schema/src/main/resources/META-INF/db/schema-42210to42220.sql
+++ b/engine/schema/src/main/resources/META-INF/db/schema-42210to42220.sql
@@ -18,3 +18,8 @@
 --;
 -- Schema upgrade from 4.22.1.0 to 4.22.2.0
 --;
+
+-- Widen the unique key on cloud_usage.usage_volume to include vm_id, so the 
cumulative and
+-- per-VM volume usage records introduced in 4.22.1 can coexist. See #13399.
+CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('id', 'cloud_usage.usage_volume');
+CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_volume', 
'id', '(volume_id ASC, created ASC, vm_id ASC)');

Reply via email to