require('dotenv').config(); const connectDB = require('../config/database'); /** * Migration: migrate_footer_ggcamp * Created: 21:41:03 11/12/2025 */ async function migrate() { try { // Kết nối database await connectDB(); console.log('Starting migration: migrate_footer_ggcamp...'); const mongoose = require('mongoose'); const fs = require('fs').promises; const path = require('path'); const Footer = require('../models/footer'); // Read footer.json file const footerJsonPath = path.join(__dirname, '../data/footer.json'); const footerData = JSON.parse(await fs.readFile(footerJsonPath, 'utf8')); // Migrate data using the model's static method await Footer.migrateFromJson(footerData); console.log('✅ Footer migration completed successfully!'); await mongoose.disconnect(); process.exit(0); } catch (error) { console.error('❌ Migration error:', error); process.exit(1); } } // Chạy migration nếu được gọi trực tiếp if (require.main === module) { migrate(); } module.exports = { migrate };