WMS_MAIN/database/migrations/20261005100000-create-wms-receiving-task.js
liufumingren 6ac3441109 feat: 收件任务体系(return_received_task)与退回权限调整
- 新增收件任务表 wms_return_received_task(自增 id 从 10000 起、批次号服务端自动生成 RT+日期+序号)
- 系统预设 id=1 历史收件;收件登记 wms_return_received 增加 return_received_task_id(缓存校验,未命中穿透建缓存)
- 任务接口:create/list/batchDelete/delete(有登记不可删、跨仓保护、has_register 筛选、register_count 统计)
- 移除 returnwaybill/returnReceived/returnUnpack 页面权限及角色组引用;权限标题「运单退回登记」改「未退登记」
2026-10-06 03:24:36 +08:00

70 lines
2.1 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';
/**
* 创建收件任务表 wms_receiving_task。
*
* 字段:批次号 batch_no、仓库ID warehouse_id(数据隔离维度)、
* 创建人 creator_id/creator_name、创建时间 created_at。
* 主键 id 自增从 10000 开始(建表后设置 AUTO_INCREMENT = 10000)。
*
* 索引:
* idx_warehouse_id(按仓库查询)
* idx_batch_no(按批次号查询)
* idx_creator_id(按创建人查询)
*/
const TABLE_NAME = 'wms_receiving_task';
const AUTO_INCREMENT_START = 10000;
module.exports = {
// eslint-disable-next-line no-unused-vars
async up(queryInterface, Sequelize) {
const { BIGINT, STRING, DATE } = Sequelize;
await queryInterface.createTable(TABLE_NAME, {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID(自增从10000开始)',
},
batch_no: {
type: STRING(50),
allowNull: false,
comment: '批次号',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID(数据隔离维度)',
},
creator_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '创建人账户ID',
},
creator_name: {
type: STRING(50),
allowNull: true,
comment: '创建人名称快照',
},
created_at: { type: DATE, allowNull: false, comment: '创建时间' },
updated_at: { type: DATE, allowNull: false, comment: '更新时间' },
});
// 自增ID从 10000 开始
await queryInterface.sequelize.query(
`ALTER TABLE ${TABLE_NAME} AUTO_INCREMENT = ${AUTO_INCREMENT_START}`
);
await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id' });
await queryInterface.addIndex(TABLE_NAME, [ 'batch_no' ], { name: 'idx_batch_no' });
await queryInterface.addIndex(TABLE_NAME, [ 'creator_id' ], { name: 'idx_creator_id' });
},
// eslint-disable-next-line no-unused-vars
async down(queryInterface, Sequelize) {
await queryInterface.dropTable(TABLE_NAME);
},
};