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.
 
 

51 lines
1.5 KiB

const { Sequelize } = require('sequelize');
// 使用与项目相同的数据库配置
const sequelize = new Sequelize('wechat_app', 'root', 'schl@2025', {
host: '1.95.162.61',
port: 3306,
dialect: 'mysql',
dialectOptions: {
connectTimeout: 30000,
},
});
async function checkChatData() {
try {
console.log('连接数据库...');
await sequelize.authenticate();
console.log('数据库连接成功!');
console.log('\n=== 最近的聊天会话 ===');
const [conversations] = await sequelize.query(
'SELECT * FROM chat_conversations ORDER BY created_at DESC LIMIT 5'
);
console.log(conversations);
console.log('\n=== 最近的聊天消息 ===');
const [messages] = await sequelize.query(
'SELECT * FROM chat_messages ORDER BY created_at DESC LIMIT 5'
);
console.log(messages);
// 检查是否有使用测试ID的记录
console.log('\n=== 检查测试ID记录 ===');
const [testRecords] = await sequelize.query(
"SELECT * FROM chat_conversations WHERE userId LIKE '%test_%' OR managerId LIKE '%test_%'"
);
console.log('测试ID记录数量:', testRecords.length);
if (testRecords.length > 0) {
console.log('发现测试ID记录:', testRecords);
} else {
console.log('未发现测试ID记录');
}
} catch (error) {
console.error('查询失败:', error);
} finally {
await sequelize.close();
console.log('\n数据库连接已关闭');
}
}
checkChatData();