1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/packages/unleash-api/scripts/migration-runner.js
2020-02-20 08:30:33 +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')),
};
},
};