-
-
Notifications
You must be signed in to change notification settings - Fork 499
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
Create seeds as in Eloquent (Laravel) #251
Comments
I was already working on something similar but then decided to drop it as it looked like unnecessary complex thing to write. Will look at how laravel does it, what I checked so far was how knex and typeorm seeding is working, but I did not really like the approach there, I saw too many things that could break easily (like the order of multiple seed files being decided by the file names). Also if one want the way knex is working already, then they can use knex directly (as it is direct dependency of MikroORM v3)... Currently for seeding purposes, there is a CLI command to execute SQL dump ( |
Looked at the link in more detail, and I kinda like it. Will try to incorporate something similar in one of 3.x releases. |
👍 +1 |
@B4nan If that would help, we could expose something similar to CustomMigrationSource for seeds if you would like to reuse the rest of knex seeding functionality, or possibility to provide custom seed ordering implementation, to reduce amount of things you'd have to reimplement from a scratch. |
@kibertoad thanks, but I will probably do it from scratch here, as I want to support it in mongo driver too. The implementation should be quite similar to migrations, so hopefully it won't be that time consuming. i might be able to reuse umzug here, or maybe get rid of it and replace it with custom shared implementation for both migrations and seeds. |
You guys may want to look at @mikro-resources/fixtures this is what I've been using. I like this approach better as it just take existing entity classes and generate random values/relations on the fly. |
I have worked with https://github.com/w3tecch/typeorm-seeding before. It was not bad, but definitely could use improvement. Currently I have written a very basic seeder for my project, but see a lot of potential in writing something with a similar api to Laravel's seeder and factory. I'd like to work in my own time on such a thing if you'd agree @B4nan. Then we could include that as a package or as command to the cli? |
Seeding would be a really nice feature. I've also worked with typeorm-seeding before. It is basically a must have for setting up and reinitialize the database for e2e testing purposes. |
I am currently switching from TypeORM to Mikro ORM. Example: https://github.com/ti-broish/api/tree/main/src/seeds |
https://laravel.com/docs/6.x/seeding
The text was updated successfully, but these errors were encountered: