47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* 为订单快递表新增打印版本号字段 ver。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
|
* @param {import('sequelize')} Sequelize Sequelize 实例
|
|
* @return {Promise<void>} 无返回值
|
|
*/
|
|
module.exports = {
|
|
/**
|
|
* 执行迁移:新增 ver 字段(幂等)。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
|
* @param {import('sequelize')} Sequelize Sequelize 实例
|
|
* @return {Promise<void>} 无返回值
|
|
*/
|
|
async up(queryInterface, Sequelize) {
|
|
const tableName = 'wms_order_express';
|
|
const columns = await queryInterface.describeTable(tableName);
|
|
|
|
if (columns.ver) {
|
|
return;
|
|
}
|
|
|
|
await queryInterface.addColumn(tableName, 'ver', {
|
|
type: Sequelize.STRING(50),
|
|
allowNull: true,
|
|
comment: '打印版本号',
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 回滚迁移:删除 ver 字段(幂等)。
|
|
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
|
* @return {Promise<void>} 无返回值
|
|
*/
|
|
async down(queryInterface) {
|
|
const tableName = 'wms_order_express';
|
|
const columns = await queryInterface.describeTable(tableName);
|
|
|
|
if (!columns.ver) {
|
|
return;
|
|
}
|
|
|
|
await queryInterface.removeColumn(tableName, 'ver');
|
|
},
|
|
};
|