#2039 LocalDateTime ignore timestamp->localdatetime as a type change

Historically LocalDateTime mapped to logical timestamp and we need to treat that to be not a change in type. Migrations then will not generate a AlterColumn migration when we start using the new logical type localdatetime.
This commit is contained in:
Rob Bygrave committed 2021-09-22 16:51:47 +12:00
1 parent a14f7a1766
commit 23cd45b5d1
2 files changed
+48 -46

No files matched your search

@@ -15,6 +15,8 @@ import java.util.Objects;
*/
public class MColumn {
private static final String LOCALDATETIME = "localdatetime";
private static final String TIMESTAMP = "timestamp";
private String name;
private String type;
private String checkConstraint;
@@ -377,7 +379,7 @@ public class MColumn {
getAlterColumn(tableName, tableWithHistory).setHistoryExclude(newColumn.historyExclude);
}
if (different(type, newColumn.type)) {
if (different(type, newColumn.type) && !localDateTime(type, newColumn.type)) {
changeBaseAttribute = true;
getAlterColumn(tableName, tableWithHistory).setType(newColumn.type);
}
@@ -465,6 +467,13 @@ public class MColumn {
}
}
/**
* Ignore the case of new type LocalDateTime which was historically mapped to Timestamp.
*/
boolean localDateTime(String type, String newType) {
return LOCALDATETIME.equalsIgnoreCase(newType) && TIMESTAMP.equalsIgnoreCase(type);
}
public void setDbMigrationInfos(List<DbMigrationInfo> dbMigrationInfos) {
this.dbMigrationInfos = dbMigrationInfos;
}