WMS_MAIN/database/migrations/20261005120000-add-receiving-task-id-to-wms-return-received.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

48 lines
1.8 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_return_received 增加收件任务ID。
*
* - addColumn receiving_task_id(BIGINT UNSIGNED NOT NULL DEFAULT 1,关联 wms_receiving_task.id)
* - 回填:所有现有行 receiving_task_id 统一更新为 1(即系统预设「历史收件」任务)
* - 索引 idx_receiving_task_id(按收件任务查询)
*/
const TABLE_NAME = 'wms_return_received';
module.exports = {
async up(queryInterface, Sequelize) {
const { BIGINT } = Sequelize;
const tableInfo = await queryInterface.describeTable(TABLE_NAME);
if (!tableInfo.receiving_task_id) {
await queryInterface.addColumn(TABLE_NAME, 'receiving_task_id', {
type: BIGINT(20).UNSIGNED,
allowNull: false,
defaultValue: 1,
comment: '收件任务ID,关联 wms_receiving_task.id;默认 1=系统预设「历史收件」',
});
}
// 显式回填:所有现有行统一为 1(系统预设「历史收件」任务)
await queryInterface.sequelize.query(
'UPDATE `' + TABLE_NAME + '` SET receiving_task_id = 1 WHERE receiving_task_id IS NULL OR receiving_task_id = 0'
);
const indexes = await queryInterface.showIndex(TABLE_NAME);
const hasIndex = (indexes || []).some(i => i.name === 'idx_receiving_task_id');
if (!hasIndex) {
await queryInterface.addIndex(TABLE_NAME, [ 'receiving_task_id' ], { name: 'idx_receiving_task_id' });
}
},
async down(queryInterface) {
const indexes = await queryInterface.showIndex(TABLE_NAME);
const hasIndex = (indexes || []).some(i => i.name === 'idx_receiving_task_id');
if (hasIndex) {
await queryInterface.removeIndex(TABLE_NAME, 'idx_receiving_task_id');
}
await queryInterface.removeColumn(TABLE_NAME, 'receiving_task_id');
},
};