'use strict'; /** * 为快递基础信息表新增 SPH/XHS/DW/JD 编码字段。 * @param {import('sequelize').QueryInterface} queryInterface 查询接口 * @param {import('sequelize')} Sequelize Sequelize 实例 * @return {Promise} 无返回值 */ module.exports = { /** * 执行迁移:新增 SPH/XHS/DW/JD 字段(幂等)。 * @param {import('sequelize').QueryInterface} queryInterface 查询接口 * @param {import('sequelize')} Sequelize Sequelize 实例 * @return {Promise} 无返回值 */ async up(queryInterface, Sequelize) { const tableName = 'wms_express'; const columns = await queryInterface.describeTable(tableName); if (!columns.SPH) { await queryInterface.addColumn(tableName, 'SPH', { type: Sequelize.STRING(255), allowNull: true, comment: 'SPH编码', }); } if (!columns.XHS) { await queryInterface.addColumn(tableName, 'XHS', { type: Sequelize.STRING(255), allowNull: true, comment: '小红书编码', }); } if (!columns.DW) { await queryInterface.addColumn(tableName, 'DW', { type: Sequelize.STRING(255), allowNull: true, comment: 'DW编码', }); } if (!columns.JD) { await queryInterface.addColumn(tableName, 'JD', { type: Sequelize.STRING(255), allowNull: true, comment: '京东编码', }); } }, /** * 回滚迁移:删除 SPH/XHS/DW/JD 字段(幂等)。 * @param {import('sequelize').QueryInterface} queryInterface 查询接口 * @return {Promise} 无返回值 */ async down(queryInterface) { const tableName = 'wms_express'; const columns = await queryInterface.describeTable(tableName); if (columns.SPH) { await queryInterface.removeColumn(tableName, 'SPH'); } if (columns.XHS) { await queryInterface.removeColumn(tableName, 'XHS'); } if (columns.DW) { await queryInterface.removeColumn(tableName, 'DW'); } if (columns.JD) { await queryInterface.removeColumn(tableName, 'JD'); } }, };