0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/server/data/migrations/init/1-create-tables.js
Katharina Irrgang 0bb81bb3c4
Bump knex-migrator to version 3.1.1 (#9199)
no issue

- adapt major changes of knex-migrator v3
- adapt migration scripts, simplify and add `down` (rollback) hook if possible
- clear Ghost cache after init hook (because of `knex-migrator migrate --init`)
- ensure db migrations work with the CLI
- updated troubleshooting guide (https://docs.ghost.org/v1/docs/troubleshooting#section-task-execute-is-not-a-function)

**For development only: Please ensure you run `npm i -g knex-migrator@latest` to update your global installation to v3. We always prefer the local installation, but v3 has modified and added binaries.**
2017-12-05 09:14:55 +01:00

29 lines
977 B
JavaScript

var Promise = require('bluebird'),
commands = require('../../schema').commands,
logging = require('../../../logging'),
schema = require('../../schema').tables,
schemaTables = Object.keys(schema);
module.exports.up = function createTables(options) {
var 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);
});
};
*/