read

After my work yesterday I sat down and worked out how to create a proper grunt plugin. Once I realised that a node module is purely a node application with a package.json this proved to be really simple. One thing that is really great is learning the npm is not just for pulling down packages from the repository but is also great for local development.

I also borrowed quite a bit from (grunt-shell)[https://npmjs.org/package/grunt-shell] to work out the best way to call the child process to run liquibase.

You can find my new grunt plugin here: grunt-liquibase

Usage is pretty straightforward:

npm install grunt-liquibase --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-liquibase');

And add a section named liquibase to the data object passed into grunt.initConfig().

grunt.initConfig({
	liquibase : {
		update: {
			options: {
				username : 'DB_USERNAME',
				password : 'DB_PASSWORD',
				url : 'jdbc:postgresql://DB_HOST:DB_PORT/DB_NAME'
			},
			command: 'update'
		},
		version : {
			command: 'version'
		}
	},
});

You can now run grunt liquibase:update and your database will be updated!

Full detail of the plugin can be found here: grunt-liquibase or at the git project page here.

Why not subscribe to my mailing list - I'll send out regular emails with new content (don't worry I won't spam you!)

* indicates required
Blog Logo

Chris Greening


Published

Image

Chris Greening

Blogging about random stuff

Back to Overview