WMS_MAIN/database/migrations/20260921150300-trim-wms-wechat-app.js

45 lines
1.7 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 表字段。
*
* 背景:令牌类字段改为由 Redis 管理(与参考实现一致),DB 只保留
* 授权状态、绑定关系与长期凭证:
* - authorizer_access_token:约 2 小时过期、高频变化,Redis 缓存 + TTL 管理,
* 落库无意义,移除。
* - access_token_expire_time:配合 access_token 的过期时间,随 access_token
* 一起由 Redis TTL 管理,移除。
* - app_secret:第三方平台模式下调用授权方接口使用 component_access_token /
* authorizer_access_token,无需小程序密钥,移除。
* - authorizer_refresh_token 保留落库:长期凭证,防 Redis 清空后需重新授权。
*/
const TABLE_NAME = 'wms_wechat_app';
module.exports = {
async up(queryInterface) {
await queryInterface.removeColumn(TABLE_NAME, 'authorizer_access_token');
await queryInterface.removeColumn(TABLE_NAME, 'access_token_expire_time');
await queryInterface.removeColumn(TABLE_NAME, 'app_secret');
},
async down(queryInterface, Sequelize) {
const { STRING, INTEGER } = Sequelize;
await queryInterface.addColumn(TABLE_NAME, 'app_secret', {
type: STRING(64),
allowNull: true,
comment: '小程序密钥(按需配置)',
});
await queryInterface.addColumn(TABLE_NAME, 'access_token_expire_time', {
type: INTEGER(11),
allowNull: true,
comment: '接口调用凭证过期时间(unix秒级时间戳)',
});
await queryInterface.addColumn(TABLE_NAME, 'authorizer_access_token', {
type: STRING(512),
allowNull: true,
comment: '授权方接口调用凭证(约2小时有效)',
});
},
};