mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
2cfee3812f
refs #6301 - changes createTable to use createTableIfNotExists, this is consistent with deletion - splits out backup, reset, update and populate functions from migration/index into their own files - moves the wrapped function for populatingDefaultSettings to fixtures.ensureDefaultSettings - moves `modelOptions` down to the fixture files that actually use it - adds test coverage for backup, reset and populate, but not for update as that needs refactoring
24 lines
625 B
JavaScript
24 lines
625 B
JavaScript
// ### 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;
|