# Generating SQL file per changeset

**URL:** <https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759>\
**Category:** General Discussion\
**Created:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759 "2013-11-12T23:56:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/1 "2013-11-12T23:56:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/2 "2013-11-12T23:56:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/3 "2013-11-12T23:56:00Z")

</div>

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

Nathan

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/4 "2013-11-12T23:56:00Z")

</div>

Really appreciate your response.  
  
1) Generate SQL means:&nbsp;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

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/5 "2013-11-12T23:56:00Z")

</div>

Hi Nathan,

&nbsp;

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&nbsp;error. Look like “MavenProject” is not getting injected. Any clue will be greately appreciated.

&nbsp;

[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  
&nbsp;(default-cli) on project LiquibaseScripts: Execution default-cli of goal test:rnd-liquibase-maven-plugin:1.0.0-DEV-SNAPSHOT:updateSQLIndividual fail  
ed.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.reflect.Method.invoke(Method.java:597)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; … 19 more  
Caused by: java.lang.NullPointerException  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.liquibase.maven.plugins.MavenUtils.getArtifactClassloader(MavenUtils.java:45)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.liquibase.maven.plugins.AbstractLiquibaseMojo.getMavenArtifactClassLoader(AbstractLiquibaseMojo.java:438)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.liquibase.maven.extension.LiquibaseUpdateSQLIndividual.getMavenArtifactClassLoader(LiquibaseUpdateSQLIndividual.java:59)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:309)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; … 20 more

&nbsp;

Thanks a lot.

&nbsp;

Best Regards - SR

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/6 "2013-11-12T23:56:00Z")

</div>

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

&nbsp; &nbsp; &nbsp;mvn liquibase:tag -Dliquibase.tag=SR

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

&nbsp; &nbsp;&nbsp;

Thanks a lot.

Best Regards - SR

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/7 "2013-11-12T23:56:00Z")

</div>

Answering question about commit/spool/tag:

There isn’t anything in liquibase to output “commit” tags yet. I created&nbsp;\<a href=“[https://liquibase.jira.com/browse/CORE-1653](https://liquibase.jira.com/browse/CORE-1653)” tag?  
  
Nathan

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [November 12, 2013, 11:56pm UTC](https://forum.liquibase.org/t/generating-sql-file-per-changeset/2759/8 "2013-11-12T23:56:00Z")

</div>

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
