Initial commit: 宁夏智慧养殖监管平台
This commit is contained in:
47
backend/check-table-columns.js
Normal file
47
backend/check-table-columns.js
Normal file
@@ -0,0 +1,47 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user