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