my project is in Springboot 3.4.4 and liquibase version - 4.29.2, I have a requirement to change the specific employee name before inserting to tables. Project uses liquibase yaml files. Have added a custom datatype for a field. Something like this:
creat_emp_table.yaml
- column:
name: emp_name
type: customnvarchar(32)
And added a java file CustomNvarchar.java , also added a registry in META-INF\services\ liquibase.datatype.LiquibaseDataType
@DataTypeInfo(name="customnvarchar",aliases = {"java.lang.String"},
minParameters = 0, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DEFAULT+1)
public class CustomNvarchar extends NVarcharType {
@Override
public String objectToSql(Object value, Database database) {
if (value != null && !"null".equals(value.toString().toLowerCase(Locale.US)) && value.toString().contains("USERA")) {
value = StringUtils.replace(value.toString(), "USERA", "USERB");
}
return super.objectToSql(value, database);
}
}
load_emp.yaml
databaseChangeLog:
- changeSet:
id: load_emp
author:
runOnChange: true
changes:
- loadUpdateData:
schemaName: ${schemaName}
tableName: emp
primaryKey: emp_id
file: emp/emp.csv
relativeToChangelogFile: true
But liquibase performs the java logic validation for all the columns for all tables irrespective of if the column is “customnvarchar” or not. This will increase our liquibase performance run time.
Please guide me if any other config needs to be added to run the java logic only for the “customnvarchar” fields.