Skip to content
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

mysql 依赖降级 #481

Closed
secwang opened this issue Dec 9, 2016 · 11 comments
Closed

mysql 依赖降级 #481

secwang opened this issue Dec 9, 2016 · 11 comments

Comments

@secwang
Copy link

secwang commented Dec 9, 2016

降级到 mysql 5.5.40 可行么, on update 我们是不是可以绕过去,我可以做这部分的支持工作

@nobodyiam
Copy link
Member

目前来看,主要是用到了两个高级特性:

  1. utf8mb4 - 这个需要5.5版本以上
  2. 一张表有多个timestamp的default值 - 这个需要5.6.5以上

所以,理论上而言,使用5.5.40也是可以的,修改一下建表语句就可以了。
把一张表中多个timestamp的default值去掉一个就可以了,代码里面应该都会设置默认值的。

@secwang
Copy link
Author

secwang commented Dec 9, 2016

utf8mb4这个没问题,timestamp 这个问题我,确认下,需要代码patch么

@nobodyiam
Copy link
Member

应该是不需要的,可以试一下把所有的DataChange_CreatedTime字段上的DEFAULT CURRENT_TIMESTAMP COMMENT改为DEFAULT '2000-01-01 00:00:00'。

代码上看,创建时间都会被程序设置的。

@PrePersist
protected void prePersist() {
    if (this.dataChangeCreatedTime == null) dataChangeCreatedTime = new Date();
    if (this.dataChangeLastModifiedTime == null) dataChangeLastModifiedTime = new Date();
}

@secwang
Copy link
Author

secwang commented Dec 9, 2016

我实验下

@secwang
Copy link
Author

secwang commented Dec 9, 2016

可行,附上我的更改脚本。

cd ~/apollo-build-scripts/sql
 perl -pi -e 's/\`DataChange_CreatedTime\` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP/\`DataChange_CreatedTime\` timestamp NOT NULL DEFAULT \'2000-01-01 00:00:00\'/g' *

@secwang secwang closed this as completed Dec 9, 2016
@secwang
Copy link
Author

secwang commented Dec 18, 2016

5.5 还存在 fulltext key 不支持 innodb 的问题,需要改为key

@nobodyiam
Copy link
Member

@secwang PR143把fulltext key改为key了。

@secwang
Copy link
Author

secwang commented Dec 23, 2016

哈哈,感谢

@lyg123
Copy link

lyg123 commented Mar 1, 2017

@nobodyiam
DEFAULT CURRENT_TIMESTAMP 改成 DEFAULT '2000-01-01 00:00:00' 吧?
我看你的有COMMENT。

@nobodyiam
Copy link
Member

@lyg123 comment无所谓的

@pgssb
Copy link

pgssb commented Apr 8, 2020

我刚刚升级了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants