import { MikroORM } from '@mikro-orm/core';
import { DatabaseSeeder } from './index';
import config from '../../../mikro-orm.config';

async function runSeeder() {
    console.log('Initializing database connection...');
    const orm = await MikroORM.init(config);
    
    try {
        const seeder = new DatabaseSeeder(orm.em);
        await seeder.run();
    } catch (error) {
        console.error('Error during seeding:', error);
        process.exit(1);
    } finally {
        await orm.close();
    }
}

runSeeder().catch(error => {
    console.error('Fatal error during seeding:', error);
    process.exit(1);
}); 