2016-10-10 15:27:31 +03:00
|
|
|
var Promise = require('bluebird'),
|
|
|
|
commands = require('../../schema').commands,
|
|
|
|
schema = require('../../schema').tables,
|
2017-12-12 00:47:46 +03:00
|
|
|
common = require('../../../lib/common'),
|
2016-10-10 15:27:31 +03:00
|
|
|
schemaTables = Object.keys(schema);
|
|
|
|
|
2017-12-05 11:14:55 +03:00
|
|
|
module.exports.up = function createTables(options) {
|
|
|
|
var connection = options.connection;
|
2016-10-10 15:27:31 +03:00
|
|
|
|
|
|
|
return Promise.mapSeries(schemaTables, function createTable(table) {
|
2017-12-12 00:47:46 +03:00
|
|
|
common.logging.info('Creating table: ' + table);
|
2017-12-05 11:14:55 +03:00
|
|
|
return commands.createTable(table, connection);
|
2016-10-10 15:27:31 +03:00
|
|
|
});
|
|
|
|
};
|
2017-12-05 11:14:55 +03:00
|
|
|
|
2017-12-12 00:47:46 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
@TODO: This works, but is very dangerous in the current state of the knex-migrator v3.
|
|
|
|
@TODO: Enable if knex-migrator v3 is stable.
|
|
|
|
module.exports.down = function dropTables(options) {
|
|
|
|
var connection = options.connection;
|
2017-12-05 11:14:55 +03:00
|
|
|
|
2017-12-12 00:47:46 +03:00
|
|
|
// Reference between tables!
|
|
|
|
schemaTables.reverse();
|
|
|
|
return Promise.mapSeries(schemaTables, function dropTable(table) {
|
|
|
|
common.logging.info('Drop table: ' + table);
|
|
|
|
return commands.deleteTable(table, connection);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
*/
|