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

Create seeds as in Eloquent (Laravel) #251

Closed
AstroCorp opened this issue Dec 3, 2019 · 9 comments · Fixed by #929
Closed

Create seeds as in Eloquent (Laravel) #251

AstroCorp opened this issue Dec 3, 2019 · 9 comments · Fixed by #929
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@AstroCorp
Copy link

https://laravel.com/docs/6.x/seeding

@AstroCorp AstroCorp added the enhancement New feature or request label Dec 3, 2019
@B4nan
Copy link
Member

B4nan commented Dec 3, 2019

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 (mikro-orm database:import <file>).

@B4nan B4nan added this to the 3.x milestone Dec 11, 2019
@B4nan
Copy link
Member

B4nan commented Dec 11, 2019

Looked at the link in more detail, and I kinda like it. Will try to incorporate something similar in one of 3.x releases.

@gperdomor
Copy link

👍 +1

@B4nan B4nan modified the milestones: 3.x, 4.0 Apr 1, 2020
@B4nan B4nan mentioned this issue Apr 30, 2020
46 tasks
@kibertoad
Copy link
Contributor

@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.

@B4nan
Copy link
Member

B4nan commented May 7, 2020

@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.

@CyriacBr
Copy link
Contributor

CyriacBr commented May 29, 2020

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.

@B4nan B4nan modified the milestones: 4.0, 4.x Jun 11, 2020
@B4nan B4nan added the help wanted Extra attention is needed label Jun 11, 2020
@Langstra
Copy link
Collaborator

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?

@squareloop1
Copy link

squareloop1 commented Sep 10, 2020

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.

Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Feb 23, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Feb 23, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Feb 23, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Feb 23, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Feb 23, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Feb 25, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 1, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 1, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 1, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 2, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 2, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 2, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 3, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 5, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 5, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 5, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 5, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Mar 5, 2021
Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue Apr 18, 2021
@hkdobrev
Copy link
Contributor

hkdobrev commented Apr 20, 2021

I am currently switching from TypeORM to Mikro ORM.
I have successfully used seeds with TypeORM migrations. I had a different set of configuration options for seeds with a separate migrations table and directory for seed "migrations". Inside those migrations, I've used different techniques - from pure insert queries to converting CSV files to SQL.

Example: https://github.com/ti-broish/api/tree/main/src/seeds

Langstra added a commit to RiskChallenger/mikro-orm that referenced this issue May 13, 2021
B4nan pushed a commit that referenced this issue May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants