-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add a marten seed
management command
#147
Comments
I like the idea! I wonder if we need to allow this mechanism to be declined on a per-application basis. I assume that applications that would need to set up some pre-defined data would resort to data migrations instead of seeds. In my mind, using seeds is more something that project developers might use in order to pre-create records based on all the models provided by the installed applications. In this situation, I am under the impression that a single top-level In terms of format, do we need the require "./src/project"
# Use this file to define how your database should be seeded.
# To apply seeds, execute `marten seed`
author = Author.create!(firstname: "John", lastname: "Doe")
Article.create!(name: "Article 1", author_id: author.id)
Article.create!(name: "Article 2", author_id: author.id) |
You're right, a single This still wouldn't make the But maybe we could go first with the single |
To get further here: would it work for you if we first create a global require "./src/project"
Marten.setup
# Do not change above
# Add your seed data below And then add the What do you think @ellmetha ? |
Sounds good to me @treagod! |
Description
Let's introduce a new management command
marten seed
, to streamline the process of populating a database with initial data for Marten projects.Background:
As Marten projects evolve, it becomes increasingly important to have a reliable and efficient method for seeding the database with initial data. This initial data could include sample records, or any other essential information required for the project to function properly.
Proposal
The
marten seed
command will automate the process of seeding the database by providing a convenient interface for executing predefined seeding tasks.These tasks could be defined in a
seed.cr
file at the root of each app/project. For example the file could look like below, butCalling
marten seed
will fill your database with the data from each seed.cr inside your project/apps.A
marten seed --app=my-app
could be also beneficial to only run the seed task from one app.This task would especially useful when reloading the database frequently in development environments or initialize the database in production systems.
The text was updated successfully, but these errors were encountered: