Liquibase Java Api support

I am using Liquibase Open Source for my database deployments using a spring application. I am doing the deployments using the java API. In case of rollbacks, do them using a tag/count/date. But I want to rollback a specific or targeted SQL script. In liquibase pro, there is a maven command for doing so. I would like to know if we can do the same using java API.

My question is, is the Liquibase API different for Liquibase Open Source and Liquibase Pro?

I have done some research on this, but I could not find any different java API for pro.
Any kind of help is appreciated.
Thanks in advance

Hi @Varun,

That’s a good question. Let me ask our resident expert @NathanVoxland. In the meantime, would you mind posting a code snippet for the rollback by tag/count/date? Just for clarification.

I believe this is the rollback command you are looking to call by java api right?

Thanks,

Ronak

The API is different with the pro code. We are working on an improved “Command” API vs. the overly-large liquibase.Liquibase facade we have currently, and the Pro code is alpha testing that approach. Since we are still in progress of vetting that API, we haven’t published it yet as it will likely change in future releases.

That being said, you can see the overall structure you’d need to follow by looking at the LiquibaseRollbackOneChangeSetMojo.jar file.

You get a reference to the Command instance with code like:

        LiquibaseCommand liquibaseCommand = (CommandFactory.getInstance().getCommand("rollbackOneChangeSet"));
        AbstractSelfConfiguratingCommand configuratingCommand = (AbstractSelfConfiguratingCommand)liquibaseCommand;

and then you can add arguments to it then call liquibaseCommand.execute().

You will have to register your Pro license with Scope.getCurrentScope().getSingleton(LicenseServiceFactory.class).getLicenseService() prior to calling the liquibaseCommand.

Let me know if you’d like more details than that.

2 Likes