Scripting within Liquibase

Hi All,

I am normally using Liquibase purely for database refactoring. However, now I have to write a complex data refactoring, which seems to be beyond Liquibase’s capabilities.

The database structure is changed with Liquibase, no problem there.
The data processing however is very complex and cannot be done with simple SQL statements. I don’t want to use stored procedures because I need to support several database engines.

Can I use some kind of scripting within Liquibase which could utilize the database connection I provide ?

If Liquibase has no internal solution, I am planning to:

  • Do the initial structural refactoring with Liquibase
  • Run some Groovy scripts, passing the database connection to them. These will do the complex data modifications with the Sql object of Groovy.
  • Do the cleanup structural refactoring with Liquibase

Any comments is appreciated !!!

What we have currently is custom refactoring class support.  You can create a class that extends CustomSqlChange or CustomTaskChange and do whatever you want inside that class. 

Let me know how well they fit your needs or any questions you have.  I am working on improving the extensibility of liquibase as part of the next release for cases like this, so any feedback you have would help a lot.

Nathan

Because of the way Liquibase works, there’s no great way to execute scripting code as a change set.  You can look at the following file to get something alone those lines, but it never worked especially well: http://snipr.com/groovy-script-change  :-\

Originally posted by: RobertFischer
Because of the way Liquibase works, there's no great way to execute scripting code as a change set.  You can look at the following file to get something alone those lines, but it never worked especially well: http://snipr.com/groovy-script-change  :-\

What were you getting from Change in GroovyScriptChange that you didn’t get from CustomTaskChange ?

@Nathan
Thanks for the input

@Robert
What is wrong with your solution? You say it doesnt work well. What happens?