wdiwtlt/service/src/main/db/20151209054632-initial-schema.js
Jonathan Bernard b8c4054e09 Initial schema.
2015-12-10 18:14:16 -06:00

31 lines
886 B
JavaScript

var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
var fs = require('fs');
var path = require('path');
exports.up = function(db, callback) {
var filePath = path.join(__dirname + '/sqls/20151209054632-initial-schema-up.sql');
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return callback(err);
console.log('received data: ' + data);
db.runSql(data, function(err) {
if (err) return callback(err);
callback();
});
});
};
exports.down = function(db, callback) {
var filePath = path.join(__dirname + '/sqls/20151209054632-initial-schema-down.sql');
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return callback(err);
console.log('received data: ' + data);
db.runSql(data, function(err) {
if (err) return callback(err);
callback();
});
});
};