36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
const [ columns ] = await queryInterface.sequelize.query("SHOW COLUMNS FROM `wms_storage` LIKE 'receiving_id'");
|
|
if (columns.length > 0) {
|
|
return;
|
|
}
|
|
|
|
await queryInterface.addColumn('wms_storage', 'receiving_id', {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: true,
|
|
comment: '收货单ID',
|
|
after: 'inbound_order_no',
|
|
});
|
|
|
|
await queryInterface.addIndex('wms_storage', [ 'receiving_id' ], {
|
|
name: 'idx_receiving_id',
|
|
});
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
const [ indexes ] = await queryInterface.sequelize.query(
|
|
"SHOW INDEX FROM `wms_storage` WHERE Key_name = 'idx_receiving_id'"
|
|
);
|
|
if (indexes.length > 0) {
|
|
await queryInterface.removeIndex('wms_storage', 'idx_receiving_id');
|
|
}
|
|
|
|
const [ columns ] = await queryInterface.sequelize.query("SHOW COLUMNS FROM `wms_storage` LIKE 'receiving_id'");
|
|
if (columns.length > 0) {
|
|
await queryInterface.removeColumn('wms_storage', 'receiving_id');
|
|
}
|
|
},
|
|
};
|