-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
feat(seeder): add seeder package #929
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! left some comments here, but in general without tests or docs its hard to suggest what to change how, so please add some tests or at least adjust the description with some example usage. I don't really like the global storage, I'd expect this to work similarly to migrations or entity generator - you as a user need to initialize the ORM and get the seed manager from that - that is where the context should be, no need to have anything globally.
Do you plan to finalize this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have some comments on dependencies, staying out of the implementation part
Do you plan to continue working on this? I could pick it up myself, but I really need some docs (for the public api) and tests (or example usage) for what is done already. |
i think it would be better https://github.com/CyriacBr/mikro-resources/tree/develop/packages/fixtures as its documeneted |
@CyriacBr could you present a bit what's there and how it fits the #251? I don't really want to add more decorators and drive it that way, the idea was to have something similar to laravel. Maybe your (sorry for dumb questions, never used any kind of seeder myself, same with laravel, so this issue is rather abstract to me) |
Hello. I haven't used Laravel myself so I don't know how its Seeder behaves, but basically my package allows you to generate random entities on the fly using It was written more for testing but can be used as a CLI by creating a const orm = await MikroORM.init(ormConfig);
const factory = new FixturesFactory(ormInstance);
// Generate a fixture
const author = await factory.make(Author).oneAndPersist();
// Generate multiple fixtures
const authors = await factory.make(Author).manyAndPersist(10); But note that I haven't used MikroORM in a while so I do not know if the package is up to date with the latest release. |
Yeah I am sorry for not working on this anymore.work took up a lot of time lately. I'll try and make some documentation and code for this in the coming weekends. I'll keep you posted. |
|
I am still working on it and it is far from done, but I pushed my progress so you get a bit more feeling for and know I am working on it ;) |
68beed8
to
1526365
Compare
I think right now would be a good moment for some feedback. In my opinion it is mostly done. |
0fcc64f
to
dc1f4cd
Compare
Thanks a lot, gave it a quick scan and it looks good! Will review the code in detail soon, and ideally we can get this out in v4.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good, but i'd like to change the api to be sync as much as possible (while allowing to have async callbacks probably) to truly leverage the UoW
also the eval
should go, i dont understand why it should be needed - seeders should be exported and we should require them as we do with entities or the orm config. dont worry about the eslint rule (add ignore comment for it) - this is the right place to do it.
anyway thanks a lot for this, especially for the docs. if you would struggle with the requests, testing or with time in general, this is already in a shape where i will be happy to take over myself. if so, i'd suggest to merge this to |
Seeder would be very nice \o/ I have made a proposal for Factory API here: https://github.com/totomakers/mikro-orm/tree/seeder-propose |
So what is it? draft? wip? or ready for review? :] I see you cracked the coverage 👍 One thing I can say right ahead - I don't like the Another quick note, it looks like you have the |
Yeah, yesterday I thought I finished it, but then this morning I was like "oh shit this and this needs to be done".
We need the |
Any chance you took a look at @totomakers proposal ? |
Yeah, I used some ideas from it, but I do not like loading all SeederClasses and running them I'd like to give the user the option to run whatever seeder he/she wants. |
Yeah we want this "main seeder" that orchestrates child ones, having an array of classes is not that powerful - we need to control the flow. |
@Langstra i make some improvement in my company project. I can't share the whole project but i can let you take a peek. |
6a8aae2
to
bb65bfb
Compare
This pull request introduces 1 alert when merging bb65bfb into 9517a1d - view on LGTM.com new alerts:
|
Any suggestions for this? I believe this would be the last part of the feature to fix. Otherwise I am quite confident that the feature is ready. |
Don't worry too much about that, I am fine having it there, we should just pick a better name. Will try to look into this in more detail during weekend. |
Time has come, please rebase this and let's merge it, master is now officially 5.x. I might tweak some things/naming directly there. |
Will work on it asap, won't have time for it this weekend, but I am aiming to fix it this week. |
What about this? The rebase should be rather easy, right? :] Or did I miss it and we have new conflicts? If so, sorry about that, I guess (force) pushing won't trigger any notifications... |
Yeah I already had, but now I have rebased it again. Should be fine and pass the pipeline again. |
cool waiting for new version soon to use this |
Great job @Langstra ! |
Currently this is still a WIP, but I am opening the PR already to gather some feedback. Nothing from this code has been tested yet and I am not even sure it will transpile or pass eslint and/or prettier.
todo:
--seed
option for migration and schema fresh commandsseed:action
seed:create
command for creating a seeder classCloses #251