You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

49 lines
1.5 KiB

// 重置测试用户的同步状态
const mysql = require('mysql2/promise');
const config = require('./src/config/config');
async function resetTestUserStatus() {
console.log('===== 重置测试用户的同步状态 =====');
try {
// 连接数据库
const connection = await mysql.createConnection(config.db);
console.log('数据库连接成功');
// 测试用户信息
const testUserId = 'user_1767173385341_v8y9rhxns';
// 重置同步状态
await connection.execute(
`UPDATE ${config.tables.users.name} SET ${config.sync.statusField} = ${config.sync.unsyncedValue}, dataid = NULL WHERE userId = ?`,
[testUserId]
);
console.log(`已将测试用户 ${testUserId} 的同步状态重置为未同步,并清除了 dataid`);
// 验证重置结果
const [updatedUser] = await connection.execute(
`SELECT userId, ${config.sync.statusField}, dataid FROM ${config.tables.users.name} WHERE userId = ?`,
[testUserId]
);
if (updatedUser.length > 0) {
console.log('重置后的用户状态:', updatedUser[0]);
}
await connection.end();
console.log('\n✅ 操作完成!');
} catch (error) {
console.error('操作过程中发生错误:', error.message);
if (error.sql) {
console.error('SQL语句:', error.sql);
}
}
}
// 执行操作
resetTestUserStatus().catch(error => {
console.error('操作执行失败:', error.message);
process.exit(1);
});