47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
const { Animal, Device, Alert, Order, Farm } = require('./models');
|
|
|
|
async function checkTableColumns() {
|
|
try {
|
|
console.log('检查各表的列结构...');
|
|
|
|
// 检查farms表结构
|
|
console.log('\n=== Farms表结构 ===');
|
|
const farmAttrs = await Farm.describe();
|
|
Object.keys(farmAttrs).forEach(col => {
|
|
console.log(`${col}: ${farmAttrs[col].type}`);
|
|
});
|
|
|
|
// 检查animals表结构
|
|
console.log('\n=== Animals表结构 ===');
|
|
const animalAttrs = await Animal.describe();
|
|
Object.keys(animalAttrs).forEach(col => {
|
|
console.log(`${col}: ${animalAttrs[col].type}`);
|
|
});
|
|
|
|
// 检查devices表结构
|
|
console.log('\n=== Devices表结构 ===');
|
|
const deviceAttrs = await Device.describe();
|
|
Object.keys(deviceAttrs).forEach(col => {
|
|
console.log(`${col}: ${deviceAttrs[col].type}`);
|
|
});
|
|
|
|
// 检查alerts表结构
|
|
console.log('\n=== Alerts表结构 ===');
|
|
const alertAttrs = await Alert.describe();
|
|
Object.keys(alertAttrs).forEach(col => {
|
|
console.log(`${col}: ${alertAttrs[col].type}`);
|
|
});
|
|
|
|
// 检查orders表结构
|
|
console.log('\n=== Orders表结构 ===');
|
|
const orderAttrs = await Order.describe();
|
|
Object.keys(orderAttrs).forEach(col => {
|
|
console.log(`${col}: ${orderAttrs[col].type}`);
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('检查失败:', error.message);
|
|
}
|
|
}
|
|
|
|
checkTableColumns(); |