40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import AppDataSource from '../data-source';
|
|
import { seedUsers } from './users.seed';
|
|
import { seedCategories } from './categories.seed';
|
|
import { seedProducts } from './products.seed';
|
|
|
|
async function runSeeds() {
|
|
console.log('🌱 Starting database seeding...\n');
|
|
|
|
try {
|
|
// Initialize data source
|
|
await AppDataSource.initialize();
|
|
console.log('✓ Database connection established\n');
|
|
|
|
// Run seeds in order
|
|
console.log('👥 Seeding users...');
|
|
await seedUsers(AppDataSource);
|
|
console.log('✓ Users seeded successfully\n');
|
|
|
|
console.log('📦 Seeding categories...');
|
|
await seedCategories(AppDataSource);
|
|
console.log('✓ Categories seeded successfully\n');
|
|
|
|
console.log('📦 Seeding products...');
|
|
await seedProducts(AppDataSource);
|
|
console.log('✓ Products seeded successfully\n');
|
|
|
|
console.log('🎉 Database seeding completed successfully!');
|
|
} catch (error) {
|
|
console.error('❌ Error seeding database:', error);
|
|
process.exit(1);
|
|
} finally {
|
|
// Close connection
|
|
await AppDataSource.destroy();
|
|
console.log('\n✓ Database connection closed');
|
|
}
|
|
}
|
|
|
|
// Run seeds
|
|
runSeeds();
|