1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/scripts/migration-runner.js
2020-02-20 08:30:37 +01:00

21 lines
558 B
JavaScript

'use strict';
const fs = require('fs');
const util = require('util');
const path = require('path');
const runMigration = function (migrationPath, db, callback) {
db.runSql(fs.readFileSync(migrationPath, { encoding: 'utf8' }), callback);
};
module.exports = {
create (name) {
const format = path.resolve(__dirname, '../migrations/sql/%s.%s.sql');
return {
up: runMigration.bind(null, util.format(format, name, 'up')),
down: runMigration.bind(null, util.format(format, name, 'down')),
};
},
};