Duansg opened a new pull request, #3953: URL: https://github.com/apache/hertzbeat/pull/3953
## What's changed? 1. In the current version, although index configurations have been defined, certain issues prevent the indexes from taking effect. Enabling log output will reveal numerous error messages, such as: ``` Internal Exception: java.sql.SQLSyntaxErrorException: Key column 'alertDefineId' doesn't exist in table Error Code: 1072 Call: CREATE INDEX index_alert_define_monitor ON hzb_alert_define_monitor_bind (alertDefineId) --- Internal Exception: java.sql.SQLSyntaxErrorException: Duplicate key name 'index_alert_define_monitor' Error Code: 1061 Call: CREATE INDEX index_alert_define_monitor ON hzb_alert_define_monitor_bind (monitor_id) ``` 2. After reinitializing the project, the non-primary key indexes do not comply with the current project settings. The list is as follows: <img width="1501" height="189" alt="image" src="https://github.com/user-attachments/assets/1b29053b-9e99-4d97-83a2-294635d03648" /> 3. After analyzing the issues statistically, the following problems were identified: | Issues | Index | |----------|----------------------------------------------------------------------------------------------------------------------------------------------------------| | Index conflict | hzb_history<br>hzb_monitor<br>hzb_push_metrics<br>hzb_alert_define_monitor_bind<br>hzb_collector_monitor_bind<br>hzb_status_page_incident_component_bind | | Column name specification exception | hzb_param<br>hzb_push_metrics<br>hzb_monitor_bind<br>hzb_plugin_param<br>hzb_alert_define_monitor_bind | | Unique constraint violation exception | hzb_param | ## Modification details 1. Adjust index naming settings to ensure compatibility with different databases. 2. Added Flyway migration scripts to ensure compatibility with both initialization and upgrades. 3. Added integration tests and passed them successfully. 4. Verified index consistency for H2/MySQL/PostgreSQL during initialization or upgrade scenarios. ## Checklist - [x] I have read the [Contributing Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide) - [ ] I have written the necessary doc or comment. - [x] I have added the necessary unit tests and all cases have passed. ## Add or update API - [ ] I have added the necessary [e2e tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have passed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
