42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const TABLE_NAME = 'wms_order_express';
|
|
const WEIGHING_WEIGHT_COLUMN = 'weighing_weight';
|
|
|
|
module.exports = {
|
|
/**
|
|
* 执行迁移:为订单快递表新增称重重量字段(幂等)。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
|
|
* @param {import('sequelize')} Sequelize Sequelize 实例。
|
|
* @return {Promise<void>} 无返回值。
|
|
*/
|
|
async up(queryInterface, Sequelize) {
|
|
const columns = await queryInterface.describeTable(TABLE_NAME);
|
|
|
|
if (columns[WEIGHING_WEIGHT_COLUMN]) {
|
|
return;
|
|
}
|
|
|
|
await queryInterface.addColumn(TABLE_NAME, WEIGHING_WEIGHT_COLUMN, {
|
|
type: Sequelize.DECIMAL(10, 3),
|
|
allowNull: true,
|
|
comment: '称重重量(kg)',
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 回滚迁移:删除订单快递表称重重量字段(幂等)。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
|
|
* @return {Promise<void>} 无返回值。
|
|
*/
|
|
async down(queryInterface) {
|
|
const columns = await queryInterface.describeTable(TABLE_NAME);
|
|
|
|
if (!columns[WEIGHING_WEIGHT_COLUMN]) {
|
|
return;
|
|
}
|
|
|
|
await queryInterface.removeColumn(TABLE_NAME, WEIGHING_WEIGHT_COLUMN);
|
|
},
|
|
};
|