WMS_MAIN/database/migrations/20260923180000-add-created-at-index-to-wms-return-received.js

21 lines
735 B
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 补充登记时间索引。
* returnReceived.list 默认按 created_at desc 排序且支持 created_at 范围筛选,
* 仓库隔离为 warehouse_id,原表仅有 (warehouse_id, scan_date) 等索引,
* 登记时间过滤与排序会退化为全表扫描 + filesort,新增 (warehouse_id, created_at)
* 复合索引使范围过滤与默认排序走索引。
*/
module.exports = {
async up(queryInterface) {
await queryInterface.addIndex('wms_return_received', [ 'warehouse_id', 'created_at' ], {
name: 'idx_warehouse_created_at',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('wms_return_received', 'idx_warehouse_created_at');
},
};