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
This commit is contained in:
liufumingren 2026-08-12 22:41:32 +08:00
parent 61467756e2
commit 9974cfab89
2 changed files with 43 additions and 15 deletions

View File

@ -269,19 +269,7 @@ module.exports = app => {
order_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '订单ID(关联 wms_order.id),快递反馈建单时从 wms_order_express.order_id 填入',
},
/** 发货订单ID */
order_delivery_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '发货订单ID(关联 wms_order_delivery.id)',
},
/** 发货订单号(冗余) */
order_delivery_no: {
type: STRING(50),
allowNull: true,
comment: '发货订单号(冗余字段)',
comment: '订单ID(关联 wms_order_delivery.id)',
},
/** 入库单ID */
entry_order_id: {
@ -381,8 +369,8 @@ module.exports = app => {
fields: [ 'waybill_id' ],
},
{
name: 'idx_order_delivery_id',
fields: [ 'order_delivery_id' ],
name: 'idx_order_id',
fields: [ 'order_id' ],
},
{
name: 'idx_entry_order_id',

View File

@ -0,0 +1,40 @@
'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: '发货订单号(冗余字段)',
});
},
};