WMS_MAIN/database/migrations/20260930140000-create-wms-stock-static-check-task.js
liufumingren 190d3cf9e5 feat(stock.check): 盘点模块功能扩展并同步接口文档(0.3.227)
- 盘点明细/记录支持未知商品(stock_id 可空)与库位范围,模式/状态口径修正
- 新增静态盘点任务、公告相关模型与迁移,stock_warehouse 增加预警数量
- methods/system.json 同步盘点接口文档;headers platform 微信端取值 wx 修正为 miniprogram
2026-10-02 15:43:49 +08:00

64 lines
1.9 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_stock_static_check_task';
module.exports = {
up: async (queryInterface, Sequelize) => {
const tables = await queryInterface.showAllTables();
const exists = tables.some(t => (typeof t === 'string' ? t : t.tableName) === TABLE_NAME);
if (exists) return;
await queryInterface.createTable(TABLE_NAME, {
id: {
type: Sequelize.BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID',
},
stock_id: {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: false,
comment: '商品ID,关联 wms_stock_warehouse.id',
},
task_time: {
type: Sequelize.DATE,
allowNull: false,
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: '软删除时间',
},
}, {
comment: '静态商品盘点任务关联表(记录是否已为静态商品创建盘点任务,避免重复创建)',
});
// 核心查询:查某商品最近一次创建盘点任务时间
await queryInterface.addIndex(TABLE_NAME, [ 'stock_id', 'task_time' ], {
name: 'idx_stock_task_time',
});
// 时间范围扫描:按任务创建时间清理/统计
await queryInterface.addIndex(TABLE_NAME, [ 'task_time' ], {
name: 'idx_task_time',
});
},
down: async queryInterface => {
await queryInterface.dropTable(TABLE_NAME);
},
};