2026-02-04 17:10:58 +08:00
|
|
|
const { sequelize } = require('../db');
|
|
|
|
|
|
|
|
|
|
async function updateSystemFields() {
|
|
|
|
|
try {
|
|
|
|
|
console.log('开始更新系统字段标记...');
|
2026-03-27 19:12:16 +08:00
|
|
|
|
2026-02-04 17:10:58 +08:00
|
|
|
// 系统字段列表
|
|
|
|
|
const systemFields = [
|
2026-03-27 19:12:16 +08:00
|
|
|
'deviceId',
|
|
|
|
|
'name',
|
|
|
|
|
'type',
|
|
|
|
|
'model',
|
|
|
|
|
'serialNumber',
|
|
|
|
|
'rackId',
|
|
|
|
|
'position',
|
|
|
|
|
'height',
|
|
|
|
|
'powerConsumption',
|
|
|
|
|
'status',
|
|
|
|
|
'purchaseDate',
|
|
|
|
|
'warrantyExpiry',
|
|
|
|
|
'ipAddress',
|
|
|
|
|
'description',
|
2026-02-04 17:10:58 +08:00
|
|
|
];
|
2026-03-27 19:12:16 +08:00
|
|
|
|
2026-02-04 17:10:58 +08:00
|
|
|
// 更新系统字段标记
|
|
|
|
|
for (const fieldName of systemFields) {
|
|
|
|
|
const [result] = await sequelize.query(
|
|
|
|
|
`UPDATE deviceFields SET isSystem = 1 WHERE fieldName = '${fieldName}'`,
|
|
|
|
|
{ type: sequelize.QueryTypes.RAW }
|
|
|
|
|
);
|
|
|
|
|
console.log(`标记系统字段: ${fieldName}`);
|
|
|
|
|
}
|
2026-03-27 19:12:16 +08:00
|
|
|
|
2026-02-04 17:10:58 +08:00
|
|
|
console.log('系统字段标记更新完成');
|
|
|
|
|
process.exit(0);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('更新失败:', error);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateSystemFields();
|