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

Method dropAllTables

src/dialects/abstract/query-interface.js:285–303  ·  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

283 * @returns {Promise}
284 */
285 async dropAllTables(options) {
286 options = options || {};
287 const skip = options.skip || [];
288
289 const tableNames = await this.showAllTables(options);
290 const foreignKeys = await this.getForeignKeysForTables(tableNames, options);
291
292 for (const tableName of tableNames) {
293 let normalizedTableName = tableName;
294 if (_.isObject(tableName)) {
295 normalizedTableName = `${tableName.schema}.${tableName.tableName}`;
296 }
297
298 for (const foreignKey of foreignKeys[normalizedTableName]) {
299 await this.sequelize.query(this.queryGenerator.dropForeignKeyQuery(tableName, foreignKey));
300 }
301 }
302 await this._dropAllTables(tableNames, skip, options);
303 }
304
305 /**
306 * Rename a table

Callers 3

clearDatabaseFunction · 0.45
testFunction · 0.45

Calls 5

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

Tested by 1

testFunction · 0.36