Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does liquibase give access to java.sql.Connection for custom tasks

Tags:

liquibase

Is there a way of having liquibase call a custom Java class/plugin and giving that class access to the underlying connection to make data changes. I had a look but it only

So of our update steps require extensive data manipulation which is far far easier to do and debug in code than using SQL. So I would want to write tasks that can extract, transform and save data. Is that possible within the liquibase framework?

like image 589
Mike Q Avatar asked Jan 23 '12 19:01

Mike Q


1 Answers

If you are using a subclass of Change using the extension framework (liquibase.org/extensions) the generateStatements() method is passed the Database object the change is being executed against. Calling

((JdbcConnection) Database.getConnection()).getUnderlyingConnection() 

will return the java.sql.Connection used.

If you are using the CustomTaskChange interface, the execute() method that is executed is passed the same Database object you can get the connection from.

like image 61
Nathan Voxland Avatar answered Jan 01 '23 13:01

Nathan Voxland