Generating SQL file per changeset


We have a requirement where we need to generate SQL file per changeset. Is there any way to do it.

Thanks in advance.

Rgds - SR

By “generate” do you mean with generateChangeLog or diffChangeLog? If so, there is not a way to do that. You can create the files yourself during normal development and use to automatically pull them in, though.

Why do you need a separate file per changeSet? I normally recommend grouping them by file because then it is easier to control the ordering of them by just moving them around in the file.


I created to track the feature request. I’m not sure when it will make it to the top of my priority list, though.


Really appreciate your response.

1) Generate SQL means: mvn liquibase:updateSQL

  1. We don’t have access to run liquibase scripts on Live and hence we need to give SQL scripts generated from above command to DBA team. Now having SQL file per changeset also means separate rollback scripts. With this DBA team gets the flexibility to rollback any specific script if need arise.

Please suggest.

Thanks a lot.

Best Regards - SR

Hi Nathan,


I was trying to create a Maven plugin for liquibase extension. The Mojo I have created extends AbstractLiquibaseUpdateMojo. This is the first time I am writing a plugin so not added any details except few log. I then use this plugin from another maven project. When I try to run the plugin like "

mvn myGoal:updateSQLIndividual", I get below error. Look like “MavenProject” is not getting injected. Any clue will be greately appreciated.


[ERROR] Failed to execute goal test:rnd-liquibase-maven-plugin:1.0.0-DEV-SNAPSHOT:updateSQLIndividual (default-cli) on project LiquibaseScripts: Exec
ution default-cli of goal test:rnd-liquibase-maven-plugin:1.0.0-DEV-SNAPSHOT:updateSQLIndividual failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal test:rnd-liquibase-maven-plugin:1.0.0-DEV-SNAPSHOT:updateSQLIndividual
 (default-cli) on project LiquibaseScripts: Execution default-cli of goal test:rnd-liquibase-maven-plugin:1.0.0-DEV-SNAPSHOT:updateSQLIndividual fail
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
        at org.apache.maven.DefaultMaven.doExecute(
        at org.apache.maven.DefaultMaven.execute(
        at org.apache.maven.cli.MavenCli.execute(
        at org.apache.maven.cli.MavenCli.doMain(
        at org.apache.maven.cli.MavenCli.main(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal test:rnd-liquibase-maven-plugin:1.0.0-DEV-SNAPSHOT:updateS
QLIndividual failed.
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
        … 19 more
Caused by: java.lang.NullPointerException
        at org.liquibase.maven.plugins.MavenUtils.getArtifactClassloader(
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.getMavenArtifactClassLoader(
        at com.liquibase.maven.extension.LiquibaseUpdateSQLIndividual.getMavenArtifactClassLoader(
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
        … 20 more


Thanks a lot.


Best Regards - SR

Thanks Nathan.

Trying to sort out few more issues. Any help will be greatly appreciated.

  1. While generating SQL file using updateSQL - it does not include commit statement. Is there any way to include commit in the generated SQL file

  1. For Oracle database, is there any way to include SPOOL in generated SQL file

  1. To generate rollback SQL file, if I use following command, it works fine

     mvn liquibase:tag -Dliquibase.tag=SR

    but it does not work if I include below line in changeset. This can help me to run one additional command in command prompt.


Thanks a lot.

Best Regards - SR

Answering question about commit/spool/tag:

There isn’t anything in liquibase to output “commit” tags yet. I created <a href=“” tag?


With your maven question, I’ve actually not done much Maven Mojo development to understand how the dependency injection is handled. The existing liquibase maven plugin as been managed by other people for the most part. It sounds like it isn’t liquibase-specific though and you may find info in general maven development help.