Generating SQL file per changeset

Hi,


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.


Nathan

I created https://liquibase.jira.com/browse/CORE-1620 to track the feature request. I’m not sure when it will make it to the top of my priority list, though.


Nathan

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
ed.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
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(DefaultBuildPluginManager.java:110)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        … 19 more
Caused by: java.lang.NullPointerException
        at org.liquibase.maven.plugins.MavenUtils.getArtifactClassloader(MavenUtils.java:45)
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.getMavenArtifactClassLoader(AbstractLiquibaseMojo.java:438)
        at com.liquibase.maven.extension.LiquibaseUpdateSQLIndividual.getMavenArtifactClassLoader(LiquibaseUpdateSQLIndividual.java:59)
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:309)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        … 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=“https://liquibase.jira.com/browse/CORE-1653” tag?

Nathan

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.


Nathan