w3tecch / typeorm-seeding

🌱 A delightful way to seed test data into your database.
https://www.npmjs.com/package/typeorm-seeding
MIT License
887 stars 132 forks source link

Call seeder classes in a specific order #151

Closed wguerram closed 3 years ago

wguerram commented 3 years ago

Hello, is there a way to specify in what order call the seeder classes, i have feature folder structure and each folder has its own seeder class, I have problem with foreign keys that's why I need to call the classes in particular order.

I tried naming the classes with Seed002, Seed003 but didn't have effect. It seems it goes in the order of the folders.

Or is there a different approach?

I'm using this TYPEORM_SEEDING_SEEDS=*/.seed.ts

RaphaelWoude commented 3 years ago

At the moment we do not have a way to set the order of execution. However you could do something like this. https://github.com/w3tecch/typeorm-seeding/issues/91#issuecomment-685904757

wguerram commented 3 years ago

Thanks, I guess I'll to have the files in the same folder to work.

I tried putting an index.ts with a list of export * from to each seed file but the seeder is not picking up the classes doing it that way.

RaphaelWoude commented 3 years ago

Just have to have them all in the same folder for it to work. Anything else just doesn't work. I might look into dependency for seeders. Laravel has a system for this that works great and would fit your use-case