WMS_MAIN/database/migrations/20260805120000-add-express-fields-to-inbox-group.js

43 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 为 wms_inbox_group 添加快递相关字段:
* - express_interfaces:快递接口ID列表(逗号分隔)
* - system_express_code:系统快递编码
*/
module.exports = {
up: async (queryInterface, Sequelize) => {
const { STRING } = Sequelize;
// 检查列是否已存在
const tableInfo = await queryInterface.describeTable('wms_inbox_group');
if (!tableInfo.express_interfaces) {
await queryInterface.addColumn('wms_inbox_group', 'express_interfaces', {
type: STRING(500),
allowNull: true,
comment: '快递接口ID列表,逗号分隔(仅群类型为 express 时生效)',
});
}
if (!tableInfo.system_express_code) {
await queryInterface.addColumn('wms_inbox_group', 'system_express_code', {
type: STRING(50),
allowNull: true,
comment: '系统快递编码(仅群类型为 express 时必填)',
});
}
},
down: async queryInterface => {
const tableInfo = await queryInterface.describeTable('wms_inbox_group');
if (tableInfo.express_interfaces) {
await queryInterface.removeColumn('wms_inbox_group', 'express_interfaces');
}
if (tableInfo.system_express_code) {
await queryInterface.removeColumn('wms_inbox_group', 'system_express_code');
}
},
};