1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/scripts/migration-runner.js

21 lines
558 B
JavaScript
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
2016-10-26 10:43:11 +02:00
2016-06-18 21:53:18 +02:00
const fs = require('fs');
const util = require('util');
const path = require('path');
2016-07-02 11:54:50 +02:00
const runMigration = function (migrationPath, db, callback) {
2016-06-18 22:23:19 +02:00
db.runSql(fs.readFileSync(migrationPath, { encoding: 'utf8' }), callback);
};
module.exports = {
2016-07-02 11:54:50 +02:00
create (name) {
2016-06-18 21:53:18 +02:00
const format = path.resolve(__dirname, '../migrations/sql/%s.%s.sql');
return {
up: runMigration.bind(null, util.format(format, name, 'up')),
2016-06-18 21:55:46 +02:00
down: runMigration.bind(null, util.format(format, name, 'down')),
};
2016-06-18 21:55:46 +02:00
},
};