WMS_MAIN/database/migrations/20260611190000-merge-created-to-pending.js

31 lines
1.2 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 = {
/**
* 将 CREATED 状态合并到 PENDING:
* 1. 先把现有 CREATED 行更新为 PENDING
* 2. 再 ALTER TABLE 去掉 CREATED 枚举值
* @param queryInterface
*/
up: async queryInterface => {
// 先更新现有 CREATED 行
await queryInterface.sequelize.query(
"UPDATE wms_entry_order SET order_status = 'PENDING', updated_at = NOW() WHERE order_status = 'CREATED'"
);
// 再修改 ENUM 列定义,移除 CREATED
await queryInterface.sequelize.query(
"ALTER TABLE wms_entry_order MODIFY COLUMN order_status ENUM('PENDING','CONFIRMED','PARTIAL_RECEIVED','COMPLETED','CANCELLED','CREATING') NOT NULL DEFAULT 'PENDING' COMMENT '订单状态'"
);
},
/**
* 回滚:将 CREATED 加回 ENUM(数据不回退,因为无法区分哪些行原本是 CREATED)
* @param queryInterface
*/
down: async queryInterface => {
await queryInterface.sequelize.query(
"ALTER TABLE wms_entry_order MODIFY COLUMN order_status ENUM('PENDING','CONFIRMED','PARTIAL_RECEIVED','COMPLETED','CANCELLED','CREATED','CREATING') NOT NULL DEFAULT 'PENDING' COMMENT '订单状态'"
);
},
};