0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/data/migration/reset.js

24 lines
625 B
JavaScript
Raw Normal View History

// ### Reset
// Delete all tables from the database in reverse order
var Promise = require('bluebird'),
commands = require('../schema').commands,
schema = require('../schema').tables,
schemaTables = Object.keys(schema).reverse(),
reset;
/**
* # Reset
* Deletes all the tables defined in the schema
* Uses reverse order, which ensures that foreign keys are removed before the parent table
*
* @returns {Promise<*>}
*/
reset = function reset() {
return Promise.mapSeries(schemaTables, function (table) {
return commands.deleteTable(table);
});
};
module.exports = reset;