Search code examples
grailsgroovygrails-plugindatabase-migration

How do I modify a column using Grails' database migration plugin's Groovy DSL?


Can you give me an example of a groovy changeset using the modifyDataType method?

I tried this:

databaseChangeLog = {
  changeSet(author: "user", id: "5-1") {
        modifyDataType(tableName: "test", columnName: "description4", newDataType: "int(11)")
    }
}

But modifyDataType is not recognized. I also tried modifyColumn, but I get the same result.

The underlying question is: What kind of tags does the dsl support, and how are they used?


Solution

  • All Liquibase refactorings should work - the Groovy DSL mirrors the Liquibase XML. I didn't have a test for modifyDataType but added it to my test script and it worked fine - see https://github.com/grails-plugins/grails-database-migration/blob/master/testapp/price.changelog.groovy

    It'd be useful to figure out what's wrong if you could show some information about how it fails.