38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
'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);
|
||
}
|
||
},
|
||
};
|