add migrations
This commit is contained in:
parent
c38372a173
commit
e650e591d5
6 changed files with 163 additions and 0 deletions
23
migrations/db.js
Normal file
23
migrations/db.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
var pg = require('pg');
|
||||
var async = require('async');
|
||||
|
||||
// TODO: generalize
|
||||
var conString = 'psql://lamassu:lamassu@localhost/lamassu';
|
||||
|
||||
exports.query = function query(sql, cb) {
|
||||
exports.multi([sql], cb);
|
||||
};
|
||||
|
||||
exports.multi = function multi(sqls, cb) {
|
||||
pg.connect(conString, function(err, client, done) {
|
||||
if (err) throw err;
|
||||
|
||||
async.eachSeries(sqls, client.query.bind(client), function(err) {
|
||||
done(true);
|
||||
if (err) throw err;
|
||||
cb();
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue