
import dotenv from 'dotenv';
import mongoose from 'mongoose';
import Plan from '../../models/Plan';
import { seedPlansData } from './seedPlansData';

dotenv.config();

const seedPlans = async () => {
    try {
        const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/clinic-management';
        await mongoose.connect(mongoUri);
        console.log('Connected to MongoDB');

        // Delete existing plans
        await Plan.deleteMany({});
        console.log('Deleted existing plans');

        // Insert new plans
        const createdPlans = await Plan.insertMany(seedPlansData);
        console.log('Inserted new plans:', createdPlans);

        console.log('Seeding completed successfully');
        process.exit(0);
    } catch (error) {
        console.error('Error seeding plans:', error);
        process.exit(1);
    }
};

seedPlans();
