WMS_MAIN/database/migrations/20260922090000-add-login-code-to-wms-user-oauth.js

33 lines
920 B
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_user_oauth 增加 login_code 字段。
*
* 用途:扫码登录码(小程序授权/扫码登录场景),生成方式与
* wms_workbench.login_code 保持一致(前缀 + 随机,64 位,全局唯一,
* 登录码为一次性凭证,消费后作废)。
*/
const TABLE_NAME = 'wms_user_oauth';
module.exports = {
async up(queryInterface, Sequelize) {
const { STRING } = Sequelize;
await queryInterface.addColumn(TABLE_NAME, 'login_code', {
type: STRING(64),
allowNull: true,
comment: '登录码(前缀+随机,64位,全局唯一)',
});
await queryInterface.addIndex(TABLE_NAME, [ 'login_code' ], {
unique: true,
name: 'uk_login_code',
});
},
async down(queryInterface) {
await queryInterface.removeIndex(TABLE_NAME, 'uk_login_code');
await queryInterface.removeColumn(TABLE_NAME, 'login_code');
},
};