Skip to content

Liquibase plugin to suppress either SQL file output, or direct execution on database.

License

Notifications You must be signed in to change notification settings

Jurrie/liquibase-suppress-output

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Liquibase suppress output plugin

This plugin enables you to suppress either output to the SQL file generation, or applying the changes to the database directly.

Why did you create this?

Primary use case for me is because one of our clients asks to have Oracle specific P/SQL statements at the top of the SQL files we release. These are statements that you can not execute with JDBC, and thus not with Liquibase. So we have a changeSet that looks like this:

<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

	<changeSet id="Client specific statements" author="jurrie.overgoor" runAlways="true">
		<ext:suppressOutput startOrStop="start" suppress="execute"/>

		<sql>WHENEVER SQLERROR EXIT FAILURE</sql>
		<sql>ALTER SESSION ENABLE PARALLEL QUERY</sql>

		<ext:suppressOutput startOrStop="stop" suppress="execute"/>
	</changeSet>
	
</databaseChangeLog>

How to use

The plugin supports one tag 'suppressOutput'. It knows two parameters:

  • startOrStop
  • suppress

The startOrStop parameter knows two values:

  • start: this will start suppressing of either SQL file output or execution of statements on the database
  • stop: this will stop suppressing

The suppress parameter knows two values:

  • execute: this will start/stop suppressing the execution of statements on the database (using the Liquibase update and rollback commands)
  • sqlfile: this will start/stop suppressing the output to SQL file (using the Liquibase updateSQL and rollbackSQL commands)

The parameters might seem an odd choice at first, but this way the plugin can support rollback completely.

Don't forget to re-enable!

When you start suppressing either database execution or SQL file output, please remember to re-enable it again!

Effect on Liquibase's MD5 hashes

Adding a new tag to a changeSet will alter the MD5 hash. So adding ext:suppressOutput will also change the MD5 hash. But suppressing something does NOT alter the MD5 hash. So, even if a changeSet doesn't do exactly the same for update and updateSQL, the MD5 hashes generated by Liquibase are the same.

Think twice before using this plugin

Suppressing something in the SQL file output or suppressing executing statements on the database is probably not always a good thing. Even though I feel this plugin caters to some needs, I don't think it should be your first choice tackling a problem.

About

Liquibase plugin to suppress either SQL file output, or direct execution on database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages