Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(seeder): ensure SeederExecutor properly sorts seed files on fileName #642

Conversation

guillaumedeslandes
Copy link
Contributor

Seed files are expected to be run in fileName order, same as migrations.

SeederExecutor.buildEntities method in place uses the name attribute (equal to className) to sort files.

Given the two files:

  1. 001-customers.seed.ts, exporting a CustomersSeeder class
  2. 002-contracts.seed.ts, exporting a ContractsSeeder` class

And given that the ContractsSeeder tries to fetch Customer entities, the seed:run command will fail when sorting seeds by className.

This pull request changes the sort call to use the fileName attribute instead.

Signed-off-by: Guillaume Deslandes <guillaume@desland.es>
@guillaumedeslandes guillaumedeslandes changed the title fix(seeder): ensure SeederExecutor properly sort seed file on fileName fix(seeder): ensure SeederExecutor properly sorts seed files on fileName Jul 27, 2023
@tada5hi
Copy link
Owner

tada5hi commented Jul 27, 2023

thanks, good catch!
i have already checked for the filename property, but then foolishly compared the name.

@tada5hi tada5hi merged commit a9c4f92 into tada5hi:develop Jul 27, 2023
7 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 27, 2023
## [3.0.1](v3.0.0...v3.0.1) (2023-07-27)

### Bug Fixes

* export seeder entity ([4f728fd](4f728fd))
* **seeder:** ensure SeederExecutor properly sort seed file on fileName ([#642](#642)) ([a9c4f92](a9c4f92))
@github-actions
Copy link

🎉 This PR is included in version 3.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@guillaumedeslandes guillaumedeslandes deleted the fix/keep-seed-files-ordered-by-filename branch July 28, 2023 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants