Liquibase Java Api support

Hi,

I am using liquibase community edition for my database deployments using a spring application. I am doing the deployments using the java api. Incase of rollbacks , doing 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, Does liquibase java api is different for community edition and pro edition?

I have did a research on this , but I could not find any different java api for pro.
Anykind 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