47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* 为快递接口配置表新增扩展信息字段 ext_data。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
|
* @param {import('sequelize')} Sequelize Sequelize 实例
|
|
* @return {Promise<void>} 无返回值
|
|
*/
|
|
module.exports = {
|
|
/**
|
|
* 执行迁移:新增 ext_data 字段(幂等)。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
|
* @param {import('sequelize')} Sequelize Sequelize 实例
|
|
* @return {Promise<void>} 无返回值
|
|
*/
|
|
async up(queryInterface, Sequelize) {
|
|
const tableName = 'wms_express_interface';
|
|
const columns = await queryInterface.describeTable(tableName);
|
|
|
|
if (columns.ext_data) {
|
|
return;
|
|
}
|
|
|
|
await queryInterface.addColumn(tableName, 'ext_data', {
|
|
type: Sequelize.JSON,
|
|
allowNull: true,
|
|
comment: '扩展信息',
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 回滚迁移:删除 ext_data 字段(幂等)。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
|
* @return {Promise<void>} 无返回值
|
|
*/
|
|
async down(queryInterface) {
|
|
const tableName = 'wms_express_interface';
|
|
const columns = await queryInterface.describeTable(tableName);
|
|
|
|
if (!columns.ext_data) {
|
|
return;
|
|
}
|
|
|
|
await queryInterface.removeColumn(tableName, 'ext_data');
|
|
},
|
|
};
|