tlberglund / groovy-liquibase

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

Added support for liquibase feature called 'parameters' #32

Closed mbruner closed 11 years ago

mbruner commented 11 years ago

I. Liquibase resolver Liquibase allows user to define parameters which might be used in changesets.

Assume you have properties file: key1=val1 key2=val2

Then you are able to write this in script to load file:

property(file: 'file.properties')

Or set parameters explicitly:

property(name: 'key3', value: 'val3')

and then you are able to access these properties in this way:

createTable(tableName: '${key1}', ...)

II. Using parameters in Groovy Also I added ability to use Liquibase parameters directly in Groovy as regular variables:

createTable(tableName: key1, ...) createTable(tableName: "${key1}", ...)

This solution doesn't support property names containing dots like 'table.name' but this properties might be used with Liquibase resolver.

III. Type conversion All parameters from file are read as strings. I used ObjectUtil.setProperty from Liquibase core to convert string values to corresponding types.

tlberglund commented 11 years ago

Merged. Thanks for the contribution, and thanks especially for keeping the tests up to date!

I've released this to Central at 0.7.5