- 实现3D可视化性能优化(降低DPR、阴影贴图、简化光源) - 实现LOD多级细节系统,根据相机距离自动切换 - 添加设备弹出动画开关,默认关闭 - 修复设备缩放时位置偏移问题 - 更新README添加项目截图占位符 - 精简DEPLOYMENT.md文档,添加Gitee仓库支持 - 更新CHANGELOG.md记录v1.1.0版本
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
const { sequelize } = require('../db');
|
|
const { QueryTypes } = require('sequelize');
|
|
|
|
async function ensureSchema() {
|
|
try {
|
|
const dbType = sequelize.getDialect();
|
|
console.log(`Checking schema for ${dbType}...`);
|
|
|
|
if (dbType === 'sqlite') {
|
|
// Check if nicId column exists in device_ports
|
|
const [columns] = await sequelize.query("PRAGMA table_info(device_ports)");
|
|
const hasNicId = columns.some(col => col.name === 'nicId');
|
|
|
|
if (!hasNicId) {
|
|
console.log('Adding nicId column to device_ports...');
|
|
await sequelize.query('ALTER TABLE device_ports ADD COLUMN nicId VARCHAR(255) NULL REFERENCES network_cards(nicId)');
|
|
console.log('Added nicId column.');
|
|
} else {
|
|
console.log('nicId column already exists in device_ports.');
|
|
}
|
|
} else if (dbType === 'mysql') {
|
|
const [columns] = await sequelize.query(
|
|
"SHOW COLUMNS FROM `device_ports` LIKE 'nicId'",
|
|
{ type: QueryTypes.SELECT }
|
|
);
|
|
|
|
if (columns.length === 0) {
|
|
console.log('Adding nicId column to device_ports...');
|
|
await sequelize.query(
|
|
'ALTER TABLE `device_ports` ADD COLUMN `nicId` VARCHAR(255) NULL AFTER `deviceId`'
|
|
);
|
|
console.log('Added nicId column.');
|
|
} else {
|
|
console.log('nicId column already exists.');
|
|
}
|
|
}
|
|
|
|
console.log('Schema check complete.');
|
|
} catch (error) {
|
|
console.error('Schema check failed:', error);
|
|
} finally {
|
|
await sequelize.close();
|
|
}
|
|
}
|
|
|
|
ensureSchema();
|