tlberglund / groovy-liquibase

Yet Another Groovy DSL for Liquibase
Other
85 stars 66 forks source link

ToDo modifyColumn ? modifyDataType #7

Closed ErwinvanBrandwijk closed 13 years ago

ErwinvanBrandwijk commented 13 years ago

Not yet created

Now listed as modifyColumn. Isn't modifyDataType?

ErwinvanBrandwijk commented 13 years ago

Possible solution in my fork. Renamed it to modifyDataType, because you are only changing dataType import liquibase.change.core.ModifyDataTypeChange

 void modifyDataType(Map params) {
    addMapBasedChange(ModifyDataTypeChange, params, ['schemaName', 'tableName', 'columnName', 'newDataType'])
 }

changelog changeSet(author: "erwin", id: "5") { modifyDataType(tableName: "books4", columnName: "author", newDataType: "varchar(40)")

    rollback{
        modifyDataType(tableName: "books4", columnName: "author", newDataType: "varchar(50)")
    }
}

Result

mysql> DESCRIBE books4;

Field | Type | Null | Key | Default

id | bigint(20) | NO | PRI | NULL
title | varchar(50) | YES | | NULL
author | varchar(40) | YES | | NULL

mysql> DESCRIBE books4;

Field | Type | Null | Key | Default

id | bigint(20) | NO | PRI | NULL
title | varchar(50) | YES | | NULL
author | varchar(50) | YES | | NULL

ErwinvanBrandwijk commented 13 years ago

Accepted in master