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

liutianyou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new d6ce0c153a [improvement] change column definitions for 
commonAnnotations and alertFingerprints to TEXT type (#3463)
d6ce0c153a is described below

commit d6ce0c153af674438f9dc7c9389a59d3a516c718
Author: Yang Chen <[email protected]>
AuthorDate: Sat Jun 14 21:52:27 2025 +0800

    [improvement] change column definitions for commonAnnotations and 
alertFingerprints to TEXT type (#3463)
    
    Co-authored-by: Jast <[email protected]>
    Co-authored-by: tomsun28 <[email protected]>
    Co-authored-by: liutianyou <[email protected]>
---
 .../common/entity/alerter/GroupAlert.java          |  4 +-
 .../db/migration/h2/V172__update_column.sql        | 24 ++++++++
 .../db/migration/mysql/V172__update_column.sql     | 64 ++++++++++++++++++++++
 .../migration/postgresql/V172__update_column.sql   | 25 +++++++++
 4 files changed, 115 insertions(+), 2 deletions(-)

diff --git 
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/alerter/GroupAlert.java
 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/alerter/GroupAlert.java
index 536df7e427..84fb7b3251 100644
--- 
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/alerter/GroupAlert.java
+++ 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/alerter/GroupAlert.java
@@ -81,12 +81,12 @@ public class GroupAlert {
 
     @Schema(title = "Common Annotations", example = "{\"summary\": \"High CPU 
usage detected\", \"description\": \"CPU usage is back to normal for 
server1\"}")
     @Convert(converter = JsonMapAttributeConverter.class)
-    @Column(length = 4096)
+    @Column(columnDefinition = "TEXT")
     private Map<String, String> commonAnnotations;
     
     @Schema(title = "Alert Fingerprints", example = "[\"dxsdfdsf\"]")
     @Convert(converter = JsonStringListAttributeConverter.class)
-    @Column(length = 8192)
+    @Column(columnDefinition = "TEXT")
     private List<String> alertFingerprints;
 
     @Schema(title = "The creator of this record", example = "tom")
diff --git 
a/hertzbeat-manager/src/main/resources/db/migration/h2/V172__update_column.sql 
b/hertzbeat-manager/src/main/resources/db/migration/h2/V172__update_column.sql
new file mode 100644
index 0000000000..70e8c86f10
--- /dev/null
+++ 
b/hertzbeat-manager/src/main/resources/db/migration/h2/V172__update_column.sql
@@ -0,0 +1,24 @@
+-- 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.
+
+-- ensure every sql can rerun without error
+
+-- Modify common_annotations column to TEXT (H2 TEXT is equivalent to CLOB)
+ALTER TABLE HZB_ALERT_GROUP ALTER COLUMN common_annotations CLOB;
+
+-- Modify alert_fingerprints column to TEXT (H2 TEXT is equivalent to CLOB)  
+ALTER TABLE HZB_ALERT_GROUP ALTER COLUMN alert_fingerprints CLOB;
\ No newline at end of file
diff --git 
a/hertzbeat-manager/src/main/resources/db/migration/mysql/V172__update_column.sql
 
b/hertzbeat-manager/src/main/resources/db/migration/mysql/V172__update_column.sql
new file mode 100644
index 0000000000..85642b7155
--- /dev/null
+++ 
b/hertzbeat-manager/src/main/resources/db/migration/mysql/V172__update_column.sql
@@ -0,0 +1,64 @@
+-- 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.
+
+-- ensure every sql can rerun without error
+
+-- Modify hzb_alert_group table columns to TEXT type to resolve MySQL row size 
limit issue
+
+DELIMITER //
+CREATE PROCEDURE ModifyGroupAlertColumns()
+BEGIN
+    DECLARE table_exists INT;
+    DECLARE col_exists INT;
+
+    -- Check if the table exists
+    SELECT COUNT(*) INTO table_exists 
+    FROM INFORMATION_SCHEMA.TABLES 
+    WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'HZB_ALERT_GROUP';
+    
+    IF table_exists = 1 THEN
+        -- Check and modify common_annotations column to TEXT
+        SELECT COUNT(*) INTO col_exists 
+        FROM INFORMATION_SCHEMA.COLUMNS 
+        WHERE TABLE_SCHEMA = DATABASE() 
+        AND TABLE_NAME = 'HZB_ALERT_GROUP' 
+        AND COLUMN_NAME = 'common_annotations'
+        AND DATA_TYPE != 'text';
+        
+        IF col_exists = 1 THEN
+            ALTER TABLE HZB_ALERT_GROUP MODIFY COLUMN common_annotations TEXT;
+        END IF;
+        
+        -- Check and modify alert_fingerprints column to TEXT
+        SELECT COUNT(*) INTO col_exists 
+        FROM INFORMATION_SCHEMA.COLUMNS 
+        WHERE TABLE_SCHEMA = DATABASE() 
+        AND TABLE_NAME = 'HZB_ALERT_GROUP' 
+        AND COLUMN_NAME = 'alert_fingerprints'
+        AND DATA_TYPE != 'text';
+        
+        IF col_exists = 1 THEN
+            ALTER TABLE HZB_ALERT_GROUP MODIFY COLUMN alert_fingerprints TEXT;
+        END IF;
+    END IF;
+END //
+
+DELIMITER ;
+
+CALL ModifyGroupAlertColumns();
+DROP PROCEDURE IF EXISTS ModifyGroupAlertColumns;
+COMMIT;
\ No newline at end of file
diff --git 
a/hertzbeat-manager/src/main/resources/db/migration/postgresql/V172__update_column.sql
 
b/hertzbeat-manager/src/main/resources/db/migration/postgresql/V172__update_column.sql
new file mode 100644
index 0000000000..a6271b5847
--- /dev/null
+++ 
b/hertzbeat-manager/src/main/resources/db/migration/postgresql/V172__update_column.sql
@@ -0,0 +1,25 @@
+-- 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.
+
+-- ensure every sql can rerun without error
+
+-- Modify hzb_alert_group table columns to TEXT type to resolve row size limit 
issue
+
+ALTER TABLE HZB_ALERT_GROUP ALTER COLUMN common_annotations TYPE TEXT;
+ALTER TABLE HZB_ALERT_GROUP ALTER COLUMN alert_fingerprints TYPE TEXT;
+
+commit;
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to