This commit is contained in:
张成
2025-11-24 13:23:42 +08:00
commit 5d7444cd65
156 changed files with 50653 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
/**
* 同步 resume_info 表结构
* 用于创建或更新数据库表
*/
const db = require('../api/middleware/dbProxy');
async function syncResumeTable() {
console.log('🔄 开始同步 resume_info 表结构...\n');
try {
// 获取模型
const resume_info = db.getModel('resume_info');
if (!resume_info) {
console.error('❌ 无法获取 resume_info 模型');
return;
}
// 同步表结构force: true 会删除并重建表,慎用!)
// 如果表已存在且有数据,请使用 alter: true
console.log('⚠️ 注意:使用 alter: true 模式同步(保留现有数据)');
console.log('如果需要完全重建表,请修改为 force: true\n');
await resume_info.sync({ alter: true });
console.log('✅ resume_info 表同步成功!\n');
// 显示表结构
const tableInfo = await db.models.sequelize.query(
`DESCRIBE resume_info`,
{ type: db.models.sequelize.QueryTypes.SELECT }
);
console.log('📋 当前表结构:');
console.table(tableInfo.map(field => ({
字段名: field.Field,
类型: field.Type,
允许空: field.Null,
默认值: field.Default
})));
// 检查关键字段
const requiredFields = [
'id',
'sn_code',
'account_id',
'platform',
'fullName',
'gender',
'age',
'phone',
'email',
'education',
'workYears',
'expectedPosition',
'expectedSalary',
'skills',
'projectExperience',
'workExperience',
'aiSkillTags',
'aiStrengths',
'aiWeaknesses',
'aiCareerSuggestion',
'aiCompetitiveness',
'originalData',
'isActive',
'syncTime'
];
const existingFields = tableInfo.map(f => f.Field);
console.log('\n🔍 检查关键字段:');
const missingFields = [];
requiredFields.forEach(field => {
const exists = existingFields.includes(field);
console.log(` ${exists ? '✅' : '❌'} ${field}`);
if (!exists) {
missingFields.push(field);
}
});
if (missingFields.length > 0) {
console.log('\n⚠ 缺少以下字段:', missingFields.join(', '));
console.log('建议:重新运行同步或手动添加这些字段');
} else {
console.log('\n✅ 所有必需字段都存在!');
}
} catch (error) {
console.error('❌ 同步失败:', error.message);
console.error('\n详细错误:', error);
}
}
// 执行同步
syncResumeTable()
.then(() => {
console.log('\n✨ 同步完成!');
process.exit(0);
})
.catch(error => {
console.error('\n💥 执行失败:', error);
process.exit(1);
});