forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[vpc-dns]: ZSTAC-85599 fix dns record upgrade sql #4124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
zstack-robot-2
wants to merge
1
commit into
5.4.7-nexavm
from
sync/hongbo.liu/hongbo.liu-ZSTAC-85599
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| CREATE TABLE IF NOT EXISTS `zstack`.`VpcRouterDnsRecordVO` ( | ||
| `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
| `uuid` VARCHAR(32) NOT NULL, | ||
| `vpcRouterUuid` VARCHAR(32) DEFAULT NULL, | ||
| `vpcHaGroupUuid` VARCHAR(32) DEFAULT NULL, | ||
| `type` VARCHAR(16) NOT NULL DEFAULT 'A', | ||
| `domain` VARCHAR(255) NOT NULL, | ||
| `ip` VARCHAR(255) NOT NULL, | ||
| `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| `lastOpDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, | ||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `ukVpcRouterDnsRecordVOuuid` (`uuid`), | ||
| INDEX `idxVpcRouterDnsRecordVOvpcRouterUuid` (`vpcRouterUuid`), | ||
| INDEX `idxVpcRouterDnsRecordVOvpcHaGroupUuid` (`vpcHaGroupUuid`), | ||
| INDEX `idxVpcRouterDnsRecordVOtype` (`type`), | ||
| INDEX `idxVpcRouterDnsRecordVOdomain` (`domain`), | ||
| CONSTRAINT `fkVpcRouterDnsRecordVOVpcRouterVmVO` FOREIGN KEY (`vpcRouterUuid`) REFERENCES `zstack`.`VpcRouterVmVO` (`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fkVpcRouterDnsRecordVOVpcHaGroupVO` FOREIGN KEY (`vpcHaGroupUuid`) REFERENCES `zstack`.`VpcHaGroupVO` (`uuid`) ON DELETE CASCADE | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +0,0 @@ | ||
| CREATE TABLE IF NOT EXISTS `zstack`.`VpcRouterDnsRecordVO` ( | ||
| `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
| `uuid` VARCHAR(32) NOT NULL, | ||
| `vpcRouterUuid` VARCHAR(32) DEFAULT NULL, | ||
| `vpcHaGroupUuid` VARCHAR(32) DEFAULT NULL, | ||
| `type` VARCHAR(16) NOT NULL DEFAULT 'A', | ||
| `domain` VARCHAR(255) NOT NULL, | ||
| `ip` VARCHAR(255) NOT NULL, | ||
| `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| `lastOpDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, | ||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `ukVpcRouterDnsRecordVOuuid` (`uuid`), | ||
| INDEX `idxVpcRouterDnsRecordVOvpcRouterUuid` (`vpcRouterUuid`), | ||
| INDEX `idxVpcRouterDnsRecordVOvpcHaGroupUuid` (`vpcHaGroupUuid`), | ||
| INDEX `idxVpcRouterDnsRecordVOtype` (`type`), | ||
| INDEX `idxVpcRouterDnsRecordVOdomain` (`domain`), | ||
| CONSTRAINT `fkVpcRouterDnsRecordVOVpcRouterVmVO` FOREIGN KEY (`vpcRouterUuid`) REFERENCES `zstack`.`VpcRouterVmVO` (`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fkVpcRouterDnsRecordVOVpcHaGroupVO` FOREIGN KEY (`vpcHaGroupUuid`) REFERENCES `zstack`.`VpcHaGroupVO` (`uuid`) ON DELETE CASCADE | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
时间戳字段必须使用正确的默认值
这两个时间戳字段使用了
DEFAULT '0000-00-00 00:00:00',这违反了编码规范。根据项目历史经验,在 MySQL 5.7 环境中(explicit_defaults_for_timestamp=OFF),当表中已有一个带ON UPDATE CURRENT_TIMESTAMP的 TIMESTAMP 列(如lastOpDate)时,第二个 TIMESTAMP 列(如createDate)不能使用DEFAULT CURRENT_TIMESTAMP,否则会触发 MySQL Error 1293。应使用哨兵默认值
'2000-01-01 00:00:00'代替'0000-00-00 00:00:00',Java 层的PrePersist回调会在插入新记录时设置真实的创建时间戳。🔧 建议的修复方案
Based on learnings: In ZStack MySQL upgrade scripts under conf/db/upgrade/*.sql, if a table already contains a TIMESTAMP column defined with ON UPDATE CURRENT_TIMESTAMP (e.g., lastOpDate), then any second TIMESTAMP column (e.g., createDate) must NOT use DEFAULT CURRENT_TIMESTAMP. This repository's CI/validated environment uses MySQL 5.7 with explicit_defaults_for_timestamp=OFF, which can trigger MySQL Error 1293 (only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT/ON UPDATE). Use a non-CURRENT_TIMESTAMP sentinel default such as '2000-01-01 00:00:00' (and typically keep it NOT NULL), and rely on ModelServiceRefVO.PrePersist in Java to set the real creation timestamp for new JPA-managed rows.
📝 Committable suggestion
🤖 Prompt for AI Agents