'use strict'; /** * 出库单快递公司列注释同步:express_code / express_name * * 背景:WMS 可能「转快递」处理(推送 ZT 自提、实际发 YTO 圆通),`stockout.confirm` 回传的 * `packages[].logisticsCode/logisticsName` 才是实际承运;OMS 现按回传值**覆盖**这两列 * (见 app/lib/orderCallback.js#buildExpressOverride),故列语义由「推送值」变为「以回传为准」。 * * 幂等:仅当现有注释与目标评论不同时才 MODIFY(可重复执行)。 */ const TARGET = { express_code: '快递公司编码:推送为 deliveryOrder.logisticsCode,出库确认回传后按 WMS 实际承运覆盖(可能转快递)', express_name: '快递公司名称:推送时按字典解析,出库确认回传后按 WMS 实际承运覆盖', }; module.exports = { async up(queryInterface, Sequelize) { const columns = await queryInterface.describeTable('outbound_orders'); for (const [ name, comment ] of Object.entries(TARGET)) { const col = columns[name]; if (!col || col.comment === comment) continue; await queryInterface.changeColumn('outbound_orders', name, { type: name === 'express_code' ? Sequelize.STRING(50) : Sequelize.STRING(200), allowNull: true, comment, }); } }, async down(queryInterface, Sequelize) { // 注释回滚到改动前的文本(列本身不新增/不删除) const previous = { express_code: '快递公司编码(推送 deliveryOrder.logisticsCode,如 SF/STO)', express_name: '快递公司名称(按 express_companies 字典解析的快照)', }; for (const [ name, comment ] of Object.entries(previous)) { await queryInterface.changeColumn('outbound_orders', name, { type: name === 'express_code' ? Sequelize.STRING(50) : Sequelize.STRING(200), allowNull: true, comment, }); } }, };