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