1

I have a grails 3.3 project with postgres database. I am using Liquibase DB refactoring.

Firstly, there seems to be a bug in grails due to which the migrations don't pick default value constraint from Grails Domain Class. To get over this issue, I had created a custom migration file with this value :

addColumn(tableName: "task") {
    column(name: "period", type: "int4", defaultValueNumeric: 0) {
        constraints(nullable: "false")
    }
} 

I achieved my purpose since the new column added had default set to 0. However, Now if i run dbm-gorm-diff for any changes, it adds a dropDefaultValue in migrations (thus trying to undo the manual change I did)

dropDefaultValue(columnDataType: "int", columnName: "period", tableName: "task")

This is problematic since I have to take care of updating migration file each time i run the migration. What is proper fix for this ?

Siddharth Garg
  • 1,560
  • 14
  • 19
  • 1
    dbmGormDiff will never always produce the correct result and the change sets it creates should be used as a point of reference to potentially save you time. It is not intended to not require your intervention in order to make the changes you need. – James Kleeh Oct 24 '17 at 18:30
  • The proper fix is to ignore the change set it creates – James Kleeh Oct 24 '17 at 18:30
  • I see. So I should concentrate more on creating manual changesets rather than relying on dbm-gorm-diff and use it only for reference. Right ? – Siddharth Garg Oct 24 '17 at 18:35

0 Answers0