grails-database-migration
grails-database-migration copied to clipboard
Changing data types is ignored by dbm-gorm-diff
I have a Domain class Example:
class Example {
String thisIsText
String thisIsAString
static constraints = {
}
static mapping = {
thisIsText type: 'text'
}
}
and create the initial migration. That results in:
databaseChangeLog = {
changeSet(author: "alexanderfranke (generated)", id: "1465390511706-1") {
createTable(tableName: "example") {
column(autoIncrement: "true", name: "id", type: "BIGINT") {
constraints(primaryKey: "true", primaryKeyName: "examplePK")
}
column(name: "version", type: "BIGINT") {
constraints(nullable: "false")
}
column(name: "this_isastring", type: "VARCHAR(255)") {
constraints(nullable: "false")
}
column(name: "this_is_text", type: "CLOB") {
constraints(nullable: "false")
}
}
}
}
I now change the class by adding a further member variable and adding a further line to the mapping resulting in the following:
class Example {
String thisIsText
String thisIsAString
Integer aNumber
static constraints = {
}
static mapping = {
thisIsText type: 'text'
thisIsAString type: 'text'
}
}
Creating a migration now will completely ignore thisIsAString:
databaseChangeLog = {
changeSet(author: "alexanderfranke (generated)", id: "1465390799555-1") {
addColumn(tableName: "example") {
column(name: "a_number", type: "integer") {
constraints(nullable: "false")
}
}
}
}
Is that the expected behavior? I would have expected that it will alter the column from VARCHAR(255) to CLOB. After some further testing it also seems, that no migration is created when I change the type of thisIsAString to Integer.
The behavior was observed with POSTGRESQL as well as H2.
You can find the example at https://github.com/alexanderfranke/migrationTest
Thanks, Alex
The issue exists in liquibase-hibernate: https://github.com/liquibase/liquibase-hibernate/issues/48