WMS_MAIN/database/migrations/20260903150000-create-wms-workbench-member.js
liufumingren 95067aeb8a feat(wms): 工作台成员、波次范围、库存明细与报表修复等多项更新
- workbench: 工作台成员拆分 wms_workbench_member 表,下线 barcode 字段,新增绑定/移除成员接口

- order: 订单配送新增 wave_scope 波次范围字段与历史回填,自动分配快递排除备注与储位分配限制修复

- storage.transaction.list: 重写为 wms_storage_transaction 逐条明细查询,消除聚合慢查询

- stock.report: 分页默认生效、排序白名单扩充、where.stock_id 数组兼容修复

- storage.entry: quickInbound/commit 新增 noNeedNotice 通知开关

- storage.inventory.list: stock_query 支持数组多关键字并集匹配

- store: 手工单回传通知策略 notify_manual_sync

- docs: 同步接口文档与变更记录、路由表;test: 补充快递排除与储位分配限制测试
2026-09-05 22:43:38 +08:00

87 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const TABLE_NAME = 'wms_workbench_member';
/**
* Migration: create wms_workbench_member(工作台成员/用户登录副表)
* - user_id 允许为空:非系统账号用户(如未注册 wms_account 的硬件操作员)以 NULL 记录,名称存 user_name 快照。
* - 软删除(deleted_at),移除成员通过 workbench.removeMember 完成。
*
* Idempotent: 表已存在时跳过创建。
*/
module.exports = {
/**
* 执行正向迁移:创建工作台成员副表与索引。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @param {import('sequelize')} Sequelize Sequelize 实例。
* @return {Promise<void>} 无返回值。
*/
up: async (queryInterface, Sequelize) => {
const tables = await queryInterface.showAllTables();
const exists = tables.some(t => (typeof t === 'string' ? t : (t.tableName || t.name)) === TABLE_NAME);
if (exists) return;
await queryInterface.createTable(TABLE_NAME, {
id: {
type: Sequelize.BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID',
},
workbench_id: {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: false,
comment: '工作台ID,关联 wms_workbench.id',
},
user_id: {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: true,
comment: '账号ID,关联 wms_account.id;非系统账号用户为 NULL',
},
user_name: {
type: Sequelize.STRING(128),
allowNull: true,
comment: '成员名称快照(非系统账号用户显示名)',
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
comment: '更新时间',
},
deleted_at: {
type: Sequelize.DATE,
allowNull: true,
comment: '软删除时间',
},
});
// 按工作台查询成员
await queryInterface.addIndex(TABLE_NAME, [ 'workbench_id' ], {
name: 'idx_workbench_id',
});
// 按账号反查成员
await queryInterface.addIndex(TABLE_NAME, [ 'user_id' ], {
name: 'idx_user_id',
});
},
/**
* 执行回滚迁移:删除工作台成员副表。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
* @return {Promise<void>} 无返回值。
*/
down: async queryInterface => {
await queryInterface.dropTable(TABLE_NAME);
},
};