* Add a new column to a table * * ```js * queryInterface.addColumn('tableA', 'columnC', Sequelize.STRING, { * after: 'columnB' // after option is only supported by MySQL * }); * ``` * * @param {string} table Table to add column to * @param {string} key Column
(table, key, attribute, options)
| 421 | * @returns {Promise} |
| 422 | */ |
| 423 | async addColumn(table, key, attribute, options) { |
| 424 | if (!table || !key || !attribute) { |
| 425 | throw new Error('addColumn takes at least 3 arguments (table, attribute name, attribute definition)'); |
| 426 | } |
| 427 | |
| 428 | options = options || {}; |
| 429 | attribute = this.sequelize.normalizeAttribute(attribute); |
| 430 | return await this.sequelize.query(this.queryGenerator.addColumnQuery(table, key, attribute), options); |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * Remove a column from a table |