Ghost/core/server/data/migrations/init/1-create-tables.js
Vikas Potluri 00c324fa4e
Moved core/server/lib/common/logging to core/shared/logging (#11857)
- Represents that logging is shared across all parts of Ghost at present
  * moved core/server/lib/common/logging to core/shared/logging
  * updated logging path for generic imports
  * updated migration and schema imports of logging
  * updated tests and index logging import
  * 🔥 removed logging from common module
  * fixed tests
2020-05-28 19:30:23 +01:00

31 lines
1.0 KiB
JavaScript

const Promise = require('bluebird');
const commands = require('../../schema').commands;
const schema = require('../../schema').tables;
const logging = require('../../../../shared/logging');
const schemaTables = Object.keys(schema);
module.exports.up = function createTables(options) {
const connection = options.connection;
return Promise.mapSeries(schemaTables, function createTable(table) {
logging.info('Creating table: ' + table);
return commands.createTable(table, connection);
});
};
/**
*
@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;
// Reference between tables!
schemaTables.reverse();
return Promise.mapSeries(schemaTables, function dropTable(table) {
logging.info('Drop table: ' + table);
return commands.deleteTable(table, connection);
});
};
*/