Skip to content

default column values are incorrectly handled by diffs #14477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
edwardotis opened this issue Feb 9, 2017 · 6 comments
Open

default column values are incorrectly handled by diffs #14477

edwardotis opened this issue Feb 9, 2017 · 6 comments

Comments

@edwardotis
Copy link

edwardotis commented Feb 9, 2017

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

@edwardotis edwardotis changed the title deafult values are incorrectly removed by subsequent diffs deafult column values are incorrectly handled by diffs Feb 9, 2017
@edwardotis edwardotis changed the title deafult column values are incorrectly handled by diffs default column values are incorrectly handled by diffs Feb 9, 2017
@jameskleeh
Copy link
Contributor

Did you specify compile 'org.liquibase:liquibase-core:3.5.3' in your build.gradle ?

@edwardotis
Copy link
Author

Yes, I did.
compile 'org.liquibase:liquibase-core:3.5.3'

@yackx
Copy link
Contributor

yackx commented Oct 11, 2017

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

@rkrause88
Copy link

@edwardotis
it's working with the latest liquibase-core version
compile 'org.liquibase:liquibase-core:3.5.5'

@tekells-usgs
Copy link

It doesn't work with
defaultValue: false

It works with with strings, numbers, and
defaultValue: true

@cgray9
Copy link

cgray9 commented Jan 18, 2021

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'

@jdaugherty jdaugherty transferred this issue from grails/grails-database-migration Feb 20, 2025
@jdaugherty jdaugherty transferred this issue from grails/grails-data-hibernate5 Mar 13, 2025
@jdaugherty jdaugherty transferred this issue from apache/grails-data-mapping Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants