grails-database-migration
grails-database-migration copied to clipboard
default column values are incorrectly handled by diffs
Given
class Apple{
Boolean isGood = false
static mapping = {
isGood defaultValue: false
}
}
a. I have to hand correct the diff to add defaultvalueboolean:
changeSet(author: "me (generated)", id: "1486375845934-1") { addColumn(tableName: "apple") { column(name: "is_good", type: "boolean", defaultValueBoolean: false) { constraints(nullable: "false") } } }
b. After applying update, the next diff will try to remove it
changeSet(author: "me (generated)", id: "1486614694673-15") {
dropDefaultValue(columnDataType: "boolean", columnName: "is_good", tableName: "apple")
}
So basically, the plugin (or underlying libraries) break default values.
http://docs.grails.org/3.1.14/ref/Database%20Mapping/column.html
runtime 'org.grails.plugins:database-migration:2.0.0 grails 3.1.14 postgres 9.6 java 8
Did you specify compile 'org.liquibase:liquibase-core:3.5.3'
in your build.gradle ?
Yes, I did.
compile 'org.liquibase:liquibase-core:3.5.3'
FYI, I have just added the following to a domain:
valuationRate defaultValue: 100.00
And liquibase correctly detects the default, and does no longer generate a dropDefaultValue
.
org.liquibase:liquibase-core:3.5.3
Grails Version: 3.2.6
Groovy Version: 2.4.7
JVM Version: 1.8.0_121
MySQL 5.7.19-1.1.1
@edwardotis
it's working with the latest liquibase-core version
compile 'org.liquibase:liquibase-core:3.5.5'
It doesn't work with
defaultValue: false
It works with with strings, numbers, and
defaultValue: true
It seems like defaultValue
mapping doesn't work with falsy values like false
and 0
. I'm using compile 'org.liquibase:liquibase-core:3.10.1'