import { execSync } from 'child_process';
import path from 'path';

const seedScripts = [
    'seedPlans.ts',
    'seedDoctors.ts',
    'seedPatients.ts',
    'seedAdminAndTeam.ts'
];

console.log('Starting database seeding...');

try {
    for (const script of seedScripts) {
        const scriptPath = path.join(__dirname, 'seedData', script);
        console.log(`\n---------------------------------------------------------`);
        console.log(`Running ${script}...`);

        // Execute the script using ts-node
        // We use the full path to ensuring we target the right file
        execSync(`npx ts-node "${scriptPath}"`, {
            stdio: 'inherit',
            cwd: path.resolve(__dirname, '../..') // Run from src/../.. i.e. server root to match package.json context if needed, but absolute path for script helps
        });

        console.log(`Completed ${script}`);
    }

    console.log('\n---------------------------------------------------------');
    console.log('All seed scripts completed successfully.');
    process.exit(0);
} catch (error) {
    console.error('\nError during seeding:', error);
    process.exit(1);
}
