* Drop all tables from database * * @param {object} [options] query options * @param {Array} [options.skip] List of table to skip * * @returns {Promise}
(options)
| 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 |