View All Posts
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

I’ve been playing around with node.js quite a lot recently and learning about the tools ecosystem. One tool that seems to be getting a lot of attention recently is Grunt - which is billed as “The JavaScript Task Runner”. This seems to be the tool that people are suggesting should be used for automating node.js builds and other tasks.

In the little project that I’ve been playing around with I want to have a database. One of the things that we’ve found really useful developing has been liquibase. Liquibase has proved invaluable as we’ve made modifications and updates to our database schema and we’ve integrated it into our continuous build and deployment system.

This experience makes me want to integrate liquibase into my node project and to do that I think I need to get it working with grunt.

There currently isn’t a grunt plugin or a node module for calling liquibase - at some point I’ll probably get round to creating one - but for now I just want to get it up and running with grunt.

Reading through what plugins are available for grunt, the simplest integration I can see is to use grunt-shell to call out to liquibase jar and run my changelog file.

First off we need grunt-shell installed:

npm install --save-dev grunt-shell

And now we can create a Gruntfile with a task definition to call liquibase:

module.exports = function(grunt) {
  		shell: {
	        liquibase: {
	            options: {
	                stdout: true,
	                stderr : true
	            command: 'java -jar liquibase.jar ' +
	                     '--changeLogFile changelog.xml '+
	                     '--username DB_USERNAME ' +
	                     '--password DB_PASSWORD ' +
	                     '--url jdbc:postgresql://DB_HOST:DB_PORT/DB_NAME ' +
	                     '--driver org.postgresql.Driver '+
	                     '--classpath postgresql-9.3-1100.jdbc41.jar ' +

I’ve downloaded the liquibase.jar and postgresql jdbc driver already.

Now we can run grunt and apply our changeset to our database:

$ grunt shell:liquibase
Running "shell:liquibase" (shell) task
Liquibase Update Successful

Done, without errors.

Next step will be to try and package up liquibase in a proper grunt task. We should also probably be reading our database settings from somewhere as well (I’ve hard coded mine for now). But that’s a job for tomorrow…


Related Posts

Grunt Liquibase Plugin - After putting in some work, I've successfully figured out how to create a real grunt plugin. I've discovered that a node module is essentially a node application with a package.json, and with this understanding, setting up became simple. My new plugin can be found at the given link and has straightforward usage. Once installed, the plugin may be activated in your Gruntfile. The plugin's full mechanisms can be found at the mentioned link or at the git project page.

Related Videos

AI Powered Raspberry Pi Home Automation - Is this the future? - Witness the power of ChatGPT controlling home automation lights through a Raspberry Pi, making life easier with plugins. Delve into the fascinating world of large language models, redefining interactions with APIs.
AR Sudoku Solver in Your Browser: TensorFlow & Image Processing Magic - Discover how to recreate a Sudoku app using browser APIs and ecosystem advancements, and explore the image processing pipeline technique for extracting Sudoku puzzles and solving them.
Revolutionize Your Raspberry Pi Development with VSCode Remote! - Learn how to develop code on Raspberry Pi using VSCode without needing VNC or a desktop environment by setting up a remote development environment. Develop your projects more conveniently and efficiently with this powerful tool!
Arduino Badges: Improve Your Project's Visibility and Health with GitHub Actions! - Learn how to add GitHub badges to your Arduino projects, improving project visibility and attracting contributors. Set up automated build checks with GitHub Actions to prevent broken code merges.
Automating Blog Improvements with AI: Summaries, Tags, and Related Articles - Learn how to use ChatGPT to enhance your blog's homepage, create summaries and tags, find related articles, and generate post images with ease, leveraging AI to save valuable time and effort.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


> Image


A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts