Skip to content

Commit

Permalink
refactor(authentication-service): fixed repeated code in migration file
Browse files Browse the repository at this point in the history
MIGRATION CHANGE:
migration-20210318100600- fixed repeated code

gh-124
  • Loading branch information
akshatdubeysf committed Apr 28, 2021
1 parent eb71075 commit ad81955
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions services/authentication-service/migrations/20210318100600-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ exports.setup = function (options, seedLink) {
exports.up = function (db) {
var filePath = path.join(__dirname, 'sqls', '20210318100600-init-up.sql');
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
receiveData(resolve, reject, filePath);
}).then(function (data) {
return db.runSql(data);
});
Expand All @@ -36,17 +31,21 @@ exports.up = function (db) {
exports.down = function (db) {
var filePath = path.join(__dirname, 'sqls', '20210318100600-init-down.sql');
return new Promise(function (resolve, reject) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
receiveData(resolve, reject, filePath);
}).then(function (data) {
return db.runSql(data);
});
};

function receiveData(resolve, reject, filePath) {
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) {
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
}

exports._meta = {
version: 1,
};

0 comments on commit ad81955

Please sign in to comment.