'use strict'; /** * 入库单 / 出入库明细 补充 WMS entryorder.create 所需的字段: * - inbound_orders:采购单号、预期到货时间、物流信息、供应商编码、操作员编码、操作时间 * - stock_items:inventory_type(库存类型 ZP=正品 / CC=残次,对齐 WMS 入库单行级 inventoryType) */ module.exports = { async up(queryInterface, Sequelize) { const { STRING, DATE } = Sequelize; await queryInterface.addColumn('inbound_orders', 'purchase_order_code', { type: STRING(50), allowNull: true, comment: '采购单号(orderType=CGRK 时使用)', }); await queryInterface.addColumn('inbound_orders', 'expect_start_time', { type: DATE, allowNull: true, comment: '预期到货开始时间', }); await queryInterface.addColumn('inbound_orders', 'expect_end_time', { type: DATE, allowNull: true, comment: '最迟预期到货时间', }); await queryInterface.addColumn('inbound_orders', 'logistics_code', { type: STRING(50), allowNull: true, comment: '物流公司编码(WMS 标准编码,如 SF/YTO/ZTO)', }); await queryInterface.addColumn('inbound_orders', 'logistics_name', { type: STRING(200), allowNull: true, comment: '物流公司名称', }); await queryInterface.addColumn('inbound_orders', 'express_code', { type: STRING(50), allowNull: true, comment: '运单号', }); await queryInterface.addColumn('inbound_orders', 'supplier_code', { type: STRING(50), allowNull: true, comment: '供应商编码', }); await queryInterface.addColumn('inbound_orders', 'operator_code', { type: STRING(50), allowNull: true, comment: '操作员编码', }); await queryInterface.addColumn('inbound_orders', 'operate_time', { type: DATE, allowNull: true, comment: '操作时间', }); await queryInterface.addColumn('stock_items', 'inventory_type', { type: STRING(10), allowNull: false, defaultValue: 'ZP', comment: '库存类型:ZP=正品 CC=残次(对齐 WMS 入库单行级 inventoryType)', }); }, async down(queryInterface) { const cols = await queryInterface.describeTable('inbound_orders'); for (const c of [ 'purchase_order_code', 'expect_start_time', 'expect_end_time', 'logistics_code', 'logistics_name', 'express_code', 'supplier_code', 'operator_code', 'operate_time' ]) { if (cols[c]) await queryInterface.removeColumn('inbound_orders', c); } const sCols = await queryInterface.describeTable('stock_items'); if (sCols.inventory_type) await queryInterface.removeColumn('stock_items', 'inventory_type'); }, };