WMS_MAIN/database/migrations/20260730000000-add-store-id-to-wms-order-express.js
liufumingren edc164298d feat(waybill): 新增面单/运单管理模块
- 新增 systems/waybill.js 业务层:运单列表查询/详情/导出
- 新增 systemMethods/waybill/warehouse.js 入口层
- 新增 6 个迁移脚本:面单列表索引、store_id 列、物流编码/名称回填、发货单号列、货主ID回填、发货字段回填
- 更新 waybill-module-design.md 设计文档
2026-08-01 03:43:47 +08:00

50 lines
1.6 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';
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);
}
},
};