/grunt-sproc

A handy little grunt task that helps keep PostgreSQL scripts in version control.

Primary LanguageJavaScriptMIT LicenseMIT

grunt-sproc

A nice little grunt task that lets you run PostgreSQL SQL scripts. This is mostly useful for keeping things like stored procedures with other code files, making them easy to keep in version control.

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-sproc --save-dev

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

grunt.loadNpmTasks('grunt-sproc');

The "sproc" task

Overview

In your project's Gruntfile, add a section named sproc to the data object passed into grunt.initConfig().

grunt.initConfig({
  sproc: {
    default: {
      options: {
        db: 'postgres://username:password@host.name/database'
      },
      files: [{
        src: 'sql/**/*.sql',
      }]
    },
  },
});

Options

options.db

Type: String Default value: '.'

The database connection string to be used to connect to PostgreSQL.

Usage Examples

Default Options

In this example we run all the *.sql files that our glob matches.

grunt.initConfig({
  sproc: {
    default: {
      options: {
        db: 'postgres://username:password@host.name/database'
      },
      files: [{
        src: 'sql/**/*.sql',
      }]
    },
  },
});

Release History

(Nothing yet)