'use strict'; const TABLE_NAME = 'wms_order_b2b_items'; module.exports = { async up(queryInterface, Sequelize) { const { BIGINT, INTEGER, STRING, DATE } = Sequelize; await queryInterface.createTable(TABLE_NAME, { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID', }, order_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '订单ID', }, order_item_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '订单商品明细ID', }, box_no: { type: STRING(50), allowNull: false, comment: '箱号', }, quantity: { type: INTEGER(11).UNSIGNED, allowNull: false, comment: '该商品在该箱中的数量', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, comment: '更新时间', }, }); await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'order_id', 'order_item_id', 'box_no' ], { unique: true, name: 'uk_warehouse_order_item_box' }); await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'order_id' ], { name: 'idx_warehouse_order' }); await queryInterface.addIndex(TABLE_NAME, [ 'order_item_id' ], { name: 'idx_order_item' }); }, async down(queryInterface) { await queryInterface.dropTable(TABLE_NAME); }, };