WMS_MAIN/database/migrations/20260507002000-rename-wms_picking_strategy-to-wms_wave_strategy.js
liufumingren 9c2b254206 1
Co-authored-by: Copilot <copilot@github.com>
2026-05-11 08:44:27 +08:00

38 lines
1.3 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';
/**
* 将拣货策略表重命名为波次策略表。
* 幂等处理:仅在源表存在且目标表不存在时执行重命名。
*/
module.exports = {
/**
* 升级迁移:wms_picking_strategy -> wms_wave_strategy。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
*/
up: async queryInterface => {
const sourceTable = 'wms_picking_strategy';
const targetTable = 'wms_wave_strategy';
const allTables = await queryInterface.showAllTables();
const tableNames = new Set(allTables.map(table => (typeof table === 'string' ? table : table.tableName)));
if (tableNames.has(sourceTable) && !tableNames.has(targetTable)) {
await queryInterface.renameTable(sourceTable, targetTable);
}
},
/**
* 回滚迁移:wms_wave_strategy -> wms_picking_strategy。
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
*/
down: async queryInterface => {
const sourceTable = 'wms_wave_strategy';
const targetTable = 'wms_picking_strategy';
const allTables = await queryInterface.showAllTables();
const tableNames = new Set(allTables.map(table => (typeof table === 'string' ? table : table.tableName)));
if (tableNames.has(sourceTable) && !tableNames.has(targetTable)) {
await queryInterface.renameTable(sourceTable, targetTable);
}
},
};