Skip to content

Commit 0dd1285

Browse files
AlanJagerclaude
andcommitted
<fix>[conf]: ZSTAC-81566 upgrade clusterId to BIGINT
V5.3.22 added clusterId as INT but Java expects Long (BIGINT). ADD_COLUMN skips existing columns, causing Hibernate schema validation failure. Resolves: ZSTAC-81566 http://jira.zstack.io/browse/ZSTAC-81566 Change-Id: Ic0606d6f2354f75b2ef76580ce334b5a88cbabe6 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 47b59d3 commit 0dd1285

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

conf/db/upgrade/V5.5.6__schema.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,28 @@ WHERE p.type NOT IN (
192192
);
193193

194194
-- ZSTAC-81566: Persist clusterId on ModelServiceInstanceVO to survive node restart
195+
-- V5.3.22 may have already added this column as INT; ensure BIGINT to match Java Long type
195196
CALL ADD_COLUMN('ModelServiceInstanceVO', 'clusterId', 'BIGINT', 1, NULL);
196197

198+
DROP PROCEDURE IF EXISTS EnsureClusterIdBigint;
199+
DELIMITER $$
200+
CREATE PROCEDURE EnsureClusterIdBigint()
201+
BEGIN
202+
DECLARE col_type VARCHAR(64);
203+
SELECT DATA_TYPE INTO col_type
204+
FROM INFORMATION_SCHEMA.COLUMNS
205+
WHERE TABLE_SCHEMA = 'zstack'
206+
AND TABLE_NAME = 'ModelServiceInstanceVO'
207+
AND COLUMN_NAME = 'clusterId';
208+
209+
IF col_type = 'int' THEN
210+
ALTER TABLE `zstack`.`ModelServiceInstanceVO` MODIFY COLUMN `clusterId` BIGINT NULL;
211+
END IF;
212+
END$$
213+
DELIMITER ;
214+
CALL EnsureClusterIdBigint();
215+
DROP PROCEDURE IF EXISTS EnsureClusterIdBigint;
216+
197217
-- Backfill existing data from PodVO
198218
UPDATE ModelServiceInstanceVO msi
199219
INNER JOIN PodVO p ON msi.vmInstanceUuid = p.uuid

0 commit comments

Comments
 (0)