grunt-pg-utils

Grunt tasks for version control on PostgreSql stored procedures, and various utilities.

grunt-pg-utils

Grunt tasks for version control on PostgreSql stored procedures, and various utilities.

This plugin requires Grunt ~0.4.1

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-pg-utils --save-dev

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

grunt.loadNpmTasks('grunt-pg-utils');

All the following options are REQUIRED.

Type: Object
Default value: null

An Object to be passed to pg.Client(), read node-postgres documentation for possible options.

Type: String
Default value: null
Example: somedir/*.sql

Source path for Stored Procedures, used for the restore Task.

Type: String
Default value: null
Example: somedir or somedir/ or /complete/url/to/path/

Destination path for Stored Procedures, used for the backup Task.

Type: Regexp
Default value: null
Example: somefunc_[aeiou]*

Regexp used to filter the name of the Stored Procedures, used for the backup Task.

module.exports = function (grunt) {
 
  // Read different configuration file 
  var developmentConfig = grunt.file.readJSON('development.json')
    , releaseConfig = grunt.file.readJSON('release.json');
 
  var testConfig = {
    pg: {
      "user": "username",
      "password": "password",
      "database": "test",
      "host": "127.0.0.1"
    }
  };
 
  grunt.initConfig({
    pgutils: {
      connection: testConfig.pg,
      src: 'spsql/*.sql',
      dest: 'spsql/',
      spRegex: '^(sp_|fn_).*'
    },
    clean: ['spsql']
  });
 
  // Load tasks 
  grunt.loadNpmTasks('grunt-pg-utils');
  grunt.loadNpmTasks('grunt-contrib-clean');
 
  // Default task(s). 
  grunt.registerTask('default', ['clean', 'pgutils:backupSP']);
  grunt.registerTask('restore', ['pgutils:restoreSP']);
 
};

We would be happy to accept external contributions, would this be pull requests, issues, or general encouragement.

  • 30/07/2013 v0.0.1 Initial release