-
Notifications
You must be signed in to change notification settings - Fork 257
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
Auto seed #1062
Comments
Also I would like to work on this if it gets approved. |
I would start on the PR if the following pr was reviewed: #1063 I need to know if I can base on top of this pr or if this is something the loco team is not interested in. All 3 prs (including this one) and:
would improve the functionality of fixtures. |
I could also make one bigger pr if that is preferred. |
Maybe @jondot and @kaplanelad can you help/state your opinion? |
Hey @DenuxPlays, To create an auto-seed, you can use the async fn before_run(app_context: &AppContext) -> Result<()> {
if app_context.environment == Environment::Development {
Self::truncate(&app_context.db).await?;
Self::seed(
&app_context.db,
PathBuf::from("src").join("fixtures").as_path(),
)
.await?;
}
Ok(())
} I don't know if you know this example, but what is better after seeing it? Adding it as part of the hook is better than configuring it, as it allows you to add any conditions you need easily. WDYT? |
No. I would implement a feature like with migrations. |
you don't need to call truncate function. this was only an example and you still getting the seed logic |
Yeah I now
etc. Sounds like something a few others can need. |
Hi, For example:
what is your specific use case that doesnt fall in this list? |
Feature Request
Would be great if we can configure a feature named "auto-seed" which seeds data at the very first start.
Kinda like how migrations are run. Save which file/function has already and run the rest.
Describe the solution you'd like
Create a new table and save the path of the file / name of the seeder and only run if it hasn't been found.
Describe alternatives you've considered
Implement my own system but that would be kinda pointless.
The text was updated successfully, but these errors were encountered: