after claude code
This commit is contained in:
34
src/database/seeds/run-seeds.ts
Normal file
34
src/database/seeds/run-seeds.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import AppDataSource from '../data-source';
|
||||
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 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();
|
||||
Reference in New Issue
Block a user