Skip to content

Commit

Permalink
Update Liquibase change log for mysql and mariadb
Browse files Browse the repository at this point in the history
As those databases don't have sequence, add autoincrement to thoses databases.
For info, Maria db now support create sequence
  • Loading branch information
ArnaudChirat committed Jul 19, 2024
1 parent 114683d commit b75f02e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public String adaptSql(String sql)
{
return "";
}
return sql.replace("MEMORY TABLE", "TABLE").replace("ID BIGINT NOT NULL", "ID BIGINT NOT NULL AUTO_INCREMENT")
.replace("JQM_PK.nextval", "NULL").replace(" DOUBLE", " DOUBLE PRECISION")
return sql.replace("MEMORY TABLE", "TABLE")
.replace("JQM_PK.nextval", "NULL")
.replace("UNIX_MILLIS()", "ROUND(UNIX_TIMESTAMP(NOW(4)) * 1000)").replace("IN(UNNEST(?))", "IN(?)")
.replace("CURRENT_TIMESTAMP - 1 MINUTE", "(UNIX_TIMESTAMP() - 60)")
.replace("CURRENT_TIMESTAMP - ? SECOND", "(UTC_TIMESTAMP() - INTERVAL ? SECOND)").replace("FROM (VALUES(0))", "FROM DUAL")
.replace("DNS||':'||PORT", "CONCAT(DNS, ':', PORT)").replace(" TIMESTAMP ", " DATETIME(3) ")
.replace("DNS||':'||PORT", "CONCAT(DNS, ':', PORT)")
.replace("CURRENT_TIMESTAMP", "FFFFFFFFFFFFFFFFF@@@@").replace("FFFFFFFFFFFFFFFFF@@@@", "UTC_TIMESTAMP(3)")
.replace("DATETIME(3) NOT NULL", "DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3)").replace("__T__", this.tablePrefix);
.replace("__T__", this.tablePrefix);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,12 @@
<constraints nullable="true" />
</column>
</createTable>

<modifySql dbms="mariadb,mysql">
<replace replace="ID BIGINT NOT NULL" with="ID BIGINT NOT NULL AUTO_INCREMENT"/>
<replace replace=" TIMESTAMP " with=" DATETIME(3) "/>
<replace replace="DATETIME(3) NOT NULL" with="DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3)"/>
</modifySql>
</changeSet>

</databaseChangeLog>

0 comments on commit b75f02e

Please sign in to comment.