WMS_MAIN/database/migrations/20260921150200-alter-wms-wechat-app.js

44 lines
1.4 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';
/**
* wms_wechat_app 表结构微调,适配微信开放平台授权事件推送。
*
* 1. warehouse_id 改为可空:
* 授权事件(authorized/updateauthorized)由微信开放平台推送,推送时
* 仓库绑定关系尚未确定(参考流程为授权后由回跳页面再绑定仓库),
* 因此授权阶段允许 warehouse_id 为 NULL(NULL=待绑定)。
* 2. 新增 func_info(TEXT):
* 保存授权方授权给第三方平台的权限集合(api_query_auth 返回的
* authorization_info.func_info JSON 字符串)。
*/
const TABLE_NAME = 'wms_wechat_app';
module.exports = {
async up(queryInterface, Sequelize) {
const { TEXT } = Sequelize;
await queryInterface.changeColumn(TABLE_NAME, 'warehouse_id', {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: true,
comment: '仓库ID(绑定关系,NULL=已授权待绑定仓库)',
});
await queryInterface.addColumn(TABLE_NAME, 'func_info', {
type: TEXT,
allowNull: true,
comment: '授权权限集合(JSON 字符串,来自 api_query_auth)',
});
},
async down(queryInterface, Sequelize) {
await queryInterface.removeColumn(TABLE_NAME, 'func_info');
await queryInterface.changeColumn(TABLE_NAME, 'warehouse_id', {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID(小程序归属主体,绑定关系)',
});
},
};