纳入范围: - backend/ Spring Boot 多模块后端(iot-common/device/rule/data/alarm/auth) - frontend/admin/ Vue3 + Element Plus 管理后台 - Android/ 涂鸦原生 APP (com.xhai.iot) - backend/sql/ Flyway 风格迁移脚本(V2~V21) - docs/ 对接文档与设计文档 排除范围: - 构建产物: node_modules/ target/ build/ dist/ .gradle/ - 签名密钥: *.jks *.keystore (严禁入库) - 本机配置: Android/local.properties - 运行日志: logs/ *.log - AI 协作本地数据 .codebuddy/ 与第三方 demo tuya-demo/ .gitattributes 统一以 LF 存储, Windows 批处理保留 CRLF
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
const mysql = require('mysql2/promise');
|
||
|
||
(async () => {
|
||
const conn = await mysql.createConnection({
|
||
host: 'localhost',
|
||
port: 33060,
|
||
user: 'root',
|
||
password: 'root',
|
||
database: 'iot_platform'
|
||
});
|
||
|
||
// 列出所有表
|
||
const [tables] = await conn.query('SHOW TABLES');
|
||
console.log('=== 当前数据库表 ===');
|
||
tables.forEach(t => console.log(' ', Object.values(t)[0]));
|
||
|
||
// 检查 alarm 相关表
|
||
const alarmTables = ['alarm_record', 'alarm_rule', 'device_data_record'];
|
||
console.log('\n=== 检查关键表是否存在 ===');
|
||
for (const t of alarmTables) {
|
||
const [r] = await conn.query(`SELECT COUNT(*) as cnt FROM information_schema.TABLES WHERE TABLE_SCHEMA='iot_platform' AND TABLE_NAME='${t}'`);
|
||
console.log(` ${t}: ${r[0].cnt > 0 ? '✅ 存在' : '❌ 缺失'}`);
|
||
}
|
||
|
||
// 如果 alarm_record 表不存在,查看建表SQL
|
||
console.log('\n=== 尝试查找建表SQL ===');
|
||
try {
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
// 搜索后端项目中的 SQL 文件
|
||
const searchDirs = [
|
||
'F:/work/iotsaas/backend/iot-alarm/src/main/resources/',
|
||
'F:/work/iotsaas/backend/iot-device/src/main/resources/',
|
||
'F:/work/iotsaas/docker/'
|
||
];
|
||
|
||
for (const dir of searchDirs) {
|
||
if (fs.existsSync(dir)) {
|
||
const files = fs.readdirSync(dir).filter(f => f.endsWith('.sql') || f.endsWith('.xml'));
|
||
if (files.length > 0) {
|
||
console.log(`\n${dir}:`);
|
||
files.forEach(f => console.log(` - ${f}`));
|
||
}
|
||
}
|
||
}
|
||
} catch(e) { console.log('搜索出错:', e.message); }
|
||
|
||
await conn.end();
|
||
})().catch(e => console.error('错误:', e.message));
|