mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-09-21 07:55:56 +08:00
fix: MySQL5.7 NO_ZERO_IN_DATE NO_ZERO_DATE
This commit is contained in:
parent
f7dbb53aa1
commit
9bb372bde2
|
@ -259,6 +259,16 @@ public class Entity2Schema extends Field2Schema {
|
|||
Dialect dialect = Application.getPersistManagerFactory().getDialect();
|
||||
Table table = new Table(entity, dialect);
|
||||
String[] ddls = table.generateDDL(false, false);
|
||||
// Fix MySQL5.7 NO_ZERO_IN_DATE NO_ZERO_DATE
|
||||
for (int i = 0; i < ddls.length; i++) {
|
||||
String ddl = ddls[i];
|
||||
if (ddl.contains("0000-00-00")) {
|
||||
ddls[i] = ddl
|
||||
.replace("default '0000-00-00 00:00:00'", "default current_timestamp")
|
||||
.replace("default '0000-00-00'", "default current_date");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Application.getSQLExecutor().executeBatch(ddls);
|
||||
} catch (Throwable ex) {
|
||||
|
|
Loading…
Reference in a new issue