- 与出库单主表 wms_order_stockout 一对一(order_id 关联主表 id,uk_order_id 唯一), 不分表(类似 wms_order_express 运单号表),warehouse_id/store_id 维度隔离 - 字段:总箱数 total_box_count、提货车牌 pickup_plate_number、备货备注 prep_remark、 备货用时 prep_duration_seconds(秒)、是否提货 is_picked_up(Y/N)、提货时间 picked_up_at、 出库单号快照 stockout_order_code + created_at/updated_at/deleted_at - 索引:uk_order_id、idx_warehouse_id、idx_store_id、idx_stockout_order_code、 idx_pickup_plate_number、idx_is_picked_up、idx_deleted_at - 关联:OrderStockout.hasOne(OrderStockoutB2b, as='b2bWork') - 迁移 20261008193000 已在开发库(127.0.0.1:3307)执行并核验 14 列+8 索引; 生产库待随发布执行
114 lines
3.9 KiB
JavaScript
114 lines
3.9 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 创建 B2B 出库作业明细表 wms_order_stockout_b2b。
|
||
*
|
||
* 与出库单主表 wms_order_stockout 一对一(order_id 关联主表 id,uk_order_id 唯一),
|
||
* 不分表(单表全量),通过 warehouse_id/store_id 做数据隔离与检索维度,
|
||
* 类似 wms_order_express(运单号表)的落表方式。
|
||
*
|
||
* 字段:
|
||
* order_id 出库单ID(关联 wms_order_stockout.id,唯一)
|
||
* warehouse_id / store_id 仓库/货主维度
|
||
* stockout_order_code 出库单号快照(便于按单号检索)
|
||
* total_box_count 总箱数
|
||
* pickup_plate_number 提货车牌
|
||
* prep_remark 备货备注
|
||
* prep_duration_seconds 备货用时(秒)
|
||
* is_picked_up 是否提货(Y/N)
|
||
* picked_up_at 提货时间
|
||
* created_at / updated_at / deleted_at 审计与软删除
|
||
*
|
||
* 索引:
|
||
* uk_order_id(order_id 唯一)
|
||
* idx_warehouse_id / idx_store_id / idx_stockout_order_code
|
||
* idx_pickup_plate_number / idx_is_picked_up / idx_deleted_at
|
||
*/
|
||
|
||
const TABLE_NAME = 'wms_order_stockout_b2b';
|
||
|
||
module.exports = {
|
||
// eslint-disable-next-line no-unused-vars
|
||
async up(queryInterface, Sequelize) {
|
||
const { BIGINT, STRING, INTEGER, ENUM, DATE } = Sequelize;
|
||
await queryInterface.createTable(TABLE_NAME, {
|
||
id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
allowNull: false,
|
||
comment: '主键ID',
|
||
},
|
||
order_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '出库单ID,关联 wms_order_stockout.id',
|
||
},
|
||
warehouse_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '仓库ID',
|
||
},
|
||
store_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '货主ID',
|
||
},
|
||
stockout_order_code: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '出库单号快照',
|
||
},
|
||
total_box_count: {
|
||
type: INTEGER(11),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '总箱数',
|
||
},
|
||
pickup_plate_number: {
|
||
type: STRING(20),
|
||
allowNull: true,
|
||
comment: '提货车牌',
|
||
},
|
||
prep_remark: {
|
||
type: STRING(500),
|
||
allowNull: true,
|
||
comment: '备货备注',
|
||
},
|
||
prep_duration_seconds: {
|
||
type: INTEGER(11),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '备货用时(秒)',
|
||
},
|
||
is_picked_up: {
|
||
type: ENUM('Y', 'N'),
|
||
allowNull: false,
|
||
defaultValue: 'N',
|
||
comment: '是否提货:Y=已提货 N=未提货',
|
||
},
|
||
picked_up_at: {
|
||
type: DATE,
|
||
allowNull: true,
|
||
comment: '提货时间',
|
||
},
|
||
created_at: { type: DATE, allowNull: false, comment: '创建时间' },
|
||
updated_at: { type: DATE, allowNull: false, comment: '更新时间' },
|
||
deleted_at: { type: DATE, allowNull: true, comment: '软删除时间' },
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'order_id' ], { unique: true, name: 'uk_order_id' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'store_id' ], { name: 'idx_store_id' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'stockout_order_code' ], { name: 'idx_stockout_order_code' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'pickup_plate_number' ], { name: 'idx_pickup_plate_number' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'is_picked_up' ], { name: 'idx_is_picked_up' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' });
|
||
},
|
||
|
||
// eslint-disable-next-line no-unused-vars
|
||
async down(queryInterface, Sequelize) {
|
||
await queryInterface.dropTable(TABLE_NAME);
|
||
},
|
||
};
|