'use strict'; module.exports = { async up(queryInterface, Sequelize) { const tableName = 'wms_picking'; const { INTEGER } = Sequelize; const [ quantityColumns ] = await queryInterface.sequelize.query( `SHOW COLUMNS FROM \`${tableName}\` LIKE 'quantity'` ); if (quantityColumns.length === 0) { await queryInterface.addColumn(tableName, 'quantity', { type: INTEGER(10).UNSIGNED, allowNull: false, defaultValue: 1, comment: '分配数量', }); } }, async down(queryInterface) { const tableName = 'wms_picking'; const [ quantityColumns ] = await queryInterface.sequelize.query( `SHOW COLUMNS FROM \`${tableName}\` LIKE 'quantity'` ); if (quantityColumns.length > 0) { await queryInterface.removeColumn(tableName, 'quantity'); } }, };