'use strict'; /** * 入库单 WMS 推送结果留痕: * - pushed_at:推送到外部仓库的时间 * - wms_push_result:外部仓返回结果(外部单号 / 返回码 / 消息 / 原始报文)JSON * 幂等:仅当列不存在时才新增,适配已存在相关列的库。 */ module.exports = { async up(queryInterface, Sequelize) { const { DATE, JSON } = Sequelize; const cols = await queryInterface.describeTable('inbound_orders'); if (!cols.pushed_at) { await queryInterface.addColumn('inbound_orders', 'pushed_at', { type: DATE, allowNull: true, comment: 'WMS 推送时间', }); } if (!cols.wms_push_result) { await queryInterface.addColumn('inbound_orders', 'wms_push_result', { type: JSON, allowNull: true, comment: 'WMS 推送结果(外部单号/返回码/消息/原始报文)', }); } }, async down(queryInterface) { const cols = await queryInterface.describeTable('inbound_orders'); if (cols.wms_push_result) await queryInterface.removeColumn('inbound_orders', 'wms_push_result'); if (cols.pushed_at) await queryInterface.removeColumn('inbound_orders', 'pushed_at'); }, };