From 4959474dc86f9ce8df0ae5d7fdbe4ed19d772d7e Mon Sep 17 00:00:00 2001 From: "ye.zou" Date: Thu, 20 Aug 2026 00:22:54 +0800 Subject: [PATCH] [db]: allow null hostUuid on shared model cache policy Resolves: ZSTAC-87753 Primary-storage model cache policies become resource-level rows shared by all hosts; shared rows carry hostUuid NULL, so the column must be nullable. The (hostUuid, sourceRootIdentity) unique key is kept: MySQL treats NULLs as distinct, and duplicate shared rows are collapsed in code on write. Change-Id: I56dbaf8b881619479b192bca710d8d8b86e96f19 --- conf/db/upgrade/V5.5.32__schema.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/db/upgrade/V5.5.32__schema.sql b/conf/db/upgrade/V5.5.32__schema.sql index 2f7730f8c88..8f29786a5bb 100644 --- a/conf/db/upgrade/V5.5.32__schema.sql +++ b/conf/db/upgrade/V5.5.32__schema.sql @@ -406,6 +406,10 @@ PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; +-- ZSTAC-87753: primary-storage cache policies are resource-level and shared by +-- all hosts; shared rows carry hostUuid NULL, so the column must be nullable. +ALTER TABLE `zstack`.`AiHostModelCachePolicyVO` MODIFY COLUMN `hostUuid` VARCHAR(32) NULL; + CALL CREATE_INDEX('VmModelMountVO', 'idxVmModelMountVOCacheUuid', 'cacheUuid'); CALL ADD_CONSTRAINT('VmModelMountVO', 'fkVmModelMountVOAiHostModelCacheVO', 'cacheUuid', 'AiHostModelCacheVO', 'uuid', 'SET NULL');