- 新增 systems/waybill.js 业务层:运单列表查询/详情/导出 - 新增 systemMethods/waybill/warehouse.js 入口层 - 新增 6 个迁移脚本:面单列表索引、store_id 列、物流编码/名称回填、发货单号列、货主ID回填、发货字段回填 - 更新 waybill-module-design.md 设计文档
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
'use strict';
|
||
|
||
const TABLE_NAME = 'wms_order_express';
|
||
const COLUMN_NAME = 'store_id';
|
||
|
||
/**
|
||
* 获取指定表的列名集合。
|
||
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
|
||
* @param {string} tableName 表名。
|
||
* @return {Promise<Set<string>>} 列名集合。
|
||
*/
|
||
const getColumnNameSet = async (queryInterface, tableName) => {
|
||
const columns = await queryInterface.describeTable(tableName);
|
||
return new Set(Object.keys(columns));
|
||
};
|
||
|
||
module.exports = {
|
||
/**
|
||
* 执行迁移:为运单表新增货主ID字段(幂等)。
|
||
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
|
||
* @param {import('sequelize')} Sequelize Sequelize 实例。
|
||
* @return {Promise<void>} 无返回值。
|
||
*/
|
||
async up(queryInterface, Sequelize) {
|
||
const existingColumns = await getColumnNameSet(queryInterface, TABLE_NAME);
|
||
|
||
if (!existingColumns.has(COLUMN_NAME)) {
|
||
await queryInterface.addColumn(TABLE_NAME, COLUMN_NAME, {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '货主ID',
|
||
});
|
||
}
|
||
},
|
||
|
||
/**
|
||
* 回滚迁移:移除运单表的货主ID字段。
|
||
* @param {import('sequelize').QueryInterface} queryInterface 查询接口。
|
||
* @param {import('sequelize')} Sequelize Sequelize 实例。
|
||
* @return {Promise<void>} 无返回值。
|
||
*/
|
||
async down(queryInterface, Sequelize) {
|
||
const existingColumns = await getColumnNameSet(queryInterface, TABLE_NAME);
|
||
|
||
if (existingColumns.has(COLUMN_NAME)) {
|
||
await queryInterface.removeColumn(TABLE_NAME, COLUMN_NAME);
|
||
}
|
||
},
|
||
};
|