all files / node-mysql-dbdeploy/ index.js

37.5% Statements 3/8
0% Branches 0/2
0% Functions 0/3
37.5% Lines 3/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                                                                              
var deploy = require('./lib/deploy');
var ensureDB = require('./lib/ensuredb');
 
/**
 * config must be object of format
 * {
 *   "db" : {
 *     "user": "<username>",
 *     "pass": "<password>",
 *     "host": "<hostname>",
 *     "port": <port>,
 *     "database": "<database>"
 *   },
 *   "dbdeploy" {
 *     "deployFile" : "<path to deploy file>",
 *     "undoFile" : "<path to undo file>",
 *     "changelogTable": "<name of db table for changelog>",
 *     "deltas": "<path to deltas dir>"
 *   }
 * }
 *
 * E.g.
 *
 * {
 *   "db" : {
 *     "user": "root",
 *     "pass": "root",
 *     "host": "localhost",
 *     "port": 3306,
 *     "database": "test"
 *   },
 *   "dbdeploy": {
 *     "deployFile": "/tmp/dbdeploy_deploy.sql",
 *     "undoFile": "/tmp/dbdeploy_undo.sql",
 *     "changelogTable": "changelog",
 *     "deltasDir": "deltas"
 *   }
 * }
 */
module.exports = function(config, next) {
  return function() {
    ensureDB(config.db, function(err) {
      if (err) {
        return next(err);
      }
      deploy.applyAllDeltas(config, next);
    });
  };
};