MCPcopy
hub / github.com/sequelize/sequelize / dropAllTables

Method dropAllTables

lib/dialects/abstract/query-interface.js:263–281  ·  view source on GitHub ↗

* Drop all tables from database * * @param {object} [options] query options * @param {Array} [options.skip] List of table to skip * * @returns {Promise}

(options)

Source from the content-addressed store, hash-verified

261 * @returns {Promise}
262 */
263 async dropAllTables(options) {
264 options = options || {};
265 const skip = options.skip || [];
266
267 const tableNames = await this.showAllTables(options);
268 const foreignKeys = await this.getForeignKeysForTables(tableNames, options);
269
270 for (const tableName of tableNames) {
271 let normalizedTableName = tableName;
272 if (_.isObject(tableName)) {
273 normalizedTableName = `${tableName.schema}.${tableName.tableName}`;
274 }
275
276 for (const foreignKey of foreignKeys[normalizedTableName]) {
277 await this.sequelize.query(this.queryGenerator.dropForeignKeyQuery(tableName, foreignKey));
278 }
279 }
280 await this._dropAllTables(tableNames, skip, options);
281 }
282
283 /**
284 * Rename a table

Callers 3

testFunction · 0.45
clearDatabaseFunction · 0.45

Calls 5

showAllTablesMethod · 0.95
_dropAllTablesMethod · 0.95
queryMethod · 0.45
dropForeignKeyQueryMethod · 0.45

Tested by 1

testFunction · 0.36