const { sequelize } = require('../config/database');

async function checkRequiredFields() {
  try {
    console.log('检查 livestock_policies 表的必填字段...');
    
    const [rows] = await sequelize.query('DESCRIBE livestock_policies');
    
    console.log('必填字段（NOT NULL）:');
    console.log('序号 | 字段名 | 类型 | 默认值');
    console.log('-----|--------|------|--------');
    
    const requiredFields = rows.filter(row => row.Null === 'NO');
    requiredFields.forEach((row, index) => {
      console.log(`${index + 1}. ${row.Field} | ${row.Type} | ${row.Default || 'NULL'}`);
    });
    
    console.log('\n可选字段（允许NULL）:');
    console.log('序号 | 字段名 | 类型');
    console.log('-----|--------|------');
    
    const optionalFields = rows.filter(row => row.Null === 'YES');
    optionalFields.forEach((row, index) => {
      console.log(`${index + 1}. ${row.Field} | ${row.Type}`);
    });
    
  } catch (error) {
    console.error('❌ 检查字段失败:', error.message);
  } finally {
    await sequelize.close();
  }
}

checkRequiredFields();