I have added 2 new columns SCOMMENT
and SURL
for table DB_SERVER
using grails migration (liquibase)
databaseChangeLog = {
changeSet(author: "syam (generated)", id: "changelog-2.3.6") {
addColumn(tableName:"DB_SERVER"){
column(name:"SCOMMENT", type:"VARCHAR2(255 CHAR)"){
constraints(nullable: "true")
}
}
addColumn(tableName:"DB_SERVER"){
column(name:"SURL", type:"VARCHAR2(255 CHAR)"){
constraints(nullable: "true")
}
}
}
}
Initially I defined SCOMMENT
and SURL
as of 255 characters length. In the next version, I'm trying to increase the character length to 1024 using modifyColumn
as below
databaseChangeLog = {
changeSet(author: "syam (generated)", id: "changelog-2.3.7") {
// Increase maximum length of characters for scomment field in DbServer
modifyDataType(columnName:"SCOMMENT", tableName:"DB_SERVER", newDataType="VARCHAR2(1024 CHAR)")
//Increase the maximum length of characters for surl field in DbServer
modifyDataType(columnName:"SURL", tableName:"DB_SERVER", newDataType="VARCHAR2(1024 CHAR)")
}
}
When I tried to migrate, I get the following error
Error 2014-12-08 13:11:28,086 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: liquibase.exception.ValidationFailedException: Validation Failed:
2 changes have validation failures
newDataType is required, changelog-2.3.7.groovy::changelog-2.3.7::syam(generated)::(Checksum: 3:04f74b0209f64ad261e4a864fcc3c43c)
Message: liquibase.exception.ValidationFailedException: Validation Failed:
2 changes have validation failures
newDataType is required, changelog-2.3.7.groovy::changelog-2.3.7::syam (generated)::(Checksum: 3:04f74b0209f64ad261e4a864fcc3c43c)
Line | Method
->> 262 | run in java.util.concurrent.FutureTask
How could the length of characters be changed for SCOMMENT
and SURL
?
The error is a Liquibase error, not a database error. Liquibase is not seeing the newDataType attribute and so throwing a validation error but you are setting it. I'm able to run a similar changeSet with standard liquibase and xml or json so it may be a problem with the grails DSL. It may be worth opening an issue with them.
You can always fall back to the "sql" command and just pass the ALTER TABLE statement directly as well if there is a problem with the grails parsing.