- wms_account 新增 is_custom_password(TINYINT(1) NOT NULL DEFAULT 0),同步模型与迁移 20261025135000;开发库、生产库均已执行 - user.getAccountInfo 返回 is_custom_password,仍不返回 password_hash/salt/last_login_ip - 新增 user.updateUsername:仅改当前账号,服务端重名校验并排除自己,重名返回 409,更新后清理用户缓存 - 新增 user.changePassword:is_custom_password=0 时旧密码可不传,修改后置 1;再次修改必须校验旧密码;已排除操作日志避免明文密码落库 - 单测覆盖 getAccountInfo/updateUsername/changePassword,20 通过;同步 AI_METHOD_ROUTING Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 为账号表新增“是否自定义密码”标记。
|
||
*/
|
||
module.exports = {
|
||
/**
|
||
* 执行迁移:新增 is_custom_password 字段(幂等)。
|
||
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
||
* @param {import('sequelize')} Sequelize Sequelize 实例
|
||
* @return {Promise<void>} 无返回值
|
||
*/
|
||
async up(queryInterface, Sequelize) {
|
||
const tableName = 'wms_account';
|
||
const columns = await queryInterface.describeTable(tableName);
|
||
|
||
if (columns.is_custom_password) {
|
||
return;
|
||
}
|
||
|
||
await queryInterface.addColumn(tableName, 'is_custom_password', {
|
||
type: Sequelize.TINYINT(1),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '是否自定义密码:0-否,1-是',
|
||
});
|
||
},
|
||
|
||
/**
|
||
* 回滚迁移:删除 is_custom_password 字段(幂等)。
|
||
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
||
* @return {Promise<void>} 无返回值
|
||
*/
|
||
async down(queryInterface) {
|
||
const tableName = 'wms_account';
|
||
const columns = await queryInterface.describeTable(tableName);
|
||
|
||
if (!columns.is_custom_password) {
|
||
return;
|
||
}
|
||
|
||
await queryInterface.removeColumn(tableName, 'is_custom_password');
|
||
},
|
||
};
|