modify:新增小程序
This commit is contained in:
35
scripts/migrate-add-source-fields.js
Normal file
35
scripts/migrate-add-source-fields.js
Normal file
@@ -0,0 +1,35 @@
|
||||
require('dotenv').config();
|
||||
const Price = require('../src/models/Price');
|
||||
|
||||
/**
|
||||
* 数据库迁移脚本:添加数据源标识字段
|
||||
* 为现有 prices 表添加数据源区分字段
|
||||
*/
|
||||
|
||||
async function migrate() {
|
||||
console.log('🔄 开始数据库迁移:添加数据源标识字段\n');
|
||||
|
||||
try {
|
||||
await Price.migrateAddSourceFields();
|
||||
|
||||
console.log('\n' + '='.repeat(60));
|
||||
console.log('✅ 数据库迁移完成!');
|
||||
console.log('='.repeat(60));
|
||||
console.log('\n📊 新增字段说明:');
|
||||
console.log(' - price_source_code: 数据源代码(YUNNAN_STEEL_ASSOC / MY_STEEL / DE_STEEL_FACTORY)');
|
||||
console.log(' - price_source_desc: 数据源描述');
|
||||
console.log(' - data_origin: 数据来源标识(LOCAL_FILE 或 API:ENDPOINT)');
|
||||
console.log('\n🎨 数据源标识:');
|
||||
console.log(' 🔴 YUNNAN_STEEL_ASSOC - 云南钢协指导价(DEFAULT 接口)');
|
||||
console.log(' 🔵 MY_STEEL - 我的钢铁网价格(BACKUP 接口)');
|
||||
console.log(' 🟢 DE_STEEL_FACTORY - 德钢钢厂指导价(EXTENDED 接口)');
|
||||
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('\n❌ 迁移失败:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 运行迁移
|
||||
migrate();
|
||||
Reference in New Issue
Block a user