WMS_MAIN/database/migrations/20260812150000-remove-order-delivery-id-from-after-sale.js
liufumingren 9974cfab89 migrate: 移除 wms_after_sale.order_delivery_id/order_delivery_no
- migration: DROP order_delivery_id, order_delivery_no
- model: 移除两字段定义 + idx_order_delivery_id 索引
- 全部流程已统一使用 order_id
2026-08-12 22:41:32 +08:00

41 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 = {
up: async (queryInterface, Sequelize) => {
const { STRING, BIGINT } = Sequelize;
const tableName = 'wms_after_sale';
// 检查列是否存在
const [columns] = await queryInterface.sequelize.query(
`SHOW COLUMNS FROM \`${tableName}\` LIKE 'order_delivery_id'`
);
if (Array.isArray(columns) && columns.length > 0) {
await queryInterface.removeColumn(tableName, 'order_delivery_id');
}
const [columns2] = await queryInterface.sequelize.query(
`SHOW COLUMNS FROM \`${tableName}\` LIKE 'order_delivery_no'`
);
if (Array.isArray(columns2) && columns2.length > 0) {
await queryInterface.removeColumn(tableName, 'order_delivery_no');
}
},
down: async (queryInterface, Sequelize) => {
const { STRING, BIGINT } = Sequelize;
const tableName = 'wms_after_sale';
await queryInterface.addColumn(tableName, 'order_delivery_id', {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '发货订单ID(关联 wms_order_delivery.id)',
});
await queryInterface.addColumn(tableName, 'order_delivery_no', {
type: STRING(50),
allowNull: true,
comment: '发货订单号(冗余字段)',
});
},
};