require('dotenv').config(); const mongoose = require('mongoose'); async function main() { const mongoUrl = process.env.MONGODB_URI || process.env.MONGO_URL || process.env.MONGO_URI || 'mongodb://localhost:27017/eventbuzz'; await mongoose.connect(mongoUrl, { useNewUrlParser: true, useUnifiedTopology: true }); console.log('Connected to', mongoUrl); const ConciergeBot = require('../src/models/ConciergeBot'); const KnowledgeSource = require('../src/models/KnowledgeSource'); const bots = await ConciergeBot.find({}).lean(); console.log('Found', bots.length, 'chatbots'); for (const b of bots) { const eventId = b.event && b.event._id ? b.event._id : b.event; if (!eventId) continue; const existing = await KnowledgeSource.findOne({ eventId, type: 'food' }).lean(); if (existing) { console.log('Bot', b._id, 'already has food source', existing._id); continue; } const doc = { eventId, type: 'food', sourcePath: String(eventId), displayName: 'Food Recommendations', status: 'PENDING', }; const created = await KnowledgeSource.create(doc); console.log('Created food source for bot', b._id, 'sourceId', created._id); } await mongoose.disconnect(); } main().catch((err) => { console.error('Error', err); process.exit(1); });