Skip to content

Update guidance on development environment seed data. #721

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stevepolitodesign
Copy link
Contributor

Relates to this proposal for Suspenders.

We have relied on dev:prime for loading data necessary for users
to view most of the features of the app in development.

However, there were a few areas of improvement.

First, rename dev namespace to development, and rename
prime task to seed for improved clarity.

The, introduces development:seed:replant take to create parity with
the existing db:seed:replant task.

Relates to [this proposal][1] for Suspenders.

> We have relied on [`dev:prime`][2] for loading data necessary for users
to view most of the features of the app in development.
>
> However, there were a few areas of improvement.
>
> First, rename `dev` namespace to `development`, and rename
[`prime`][1] task to `seed` for improved clarity.
>
> The, introduces `development:seed:replant` take to create parity with
the existing `db:seed:replant` task.

[1]: thoughtbot/suspenders#1251
[2]: https://thoughtbot.com/blog/priming-the-pump
@@ -43,7 +43,7 @@
- Validate the associated `belongs_to` object (`user`), not the database column
(`user_id`).
- Use `db/seeds.rb` for data that is required in all environments.
- Use `dev:prime` rake task for development environment seed data.
- Use `development:seed` rake task for development environment seed data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idea (non-blocking): What would you think about using development:db:seed?

  • This would mirror the db:seed rake task, but append the environment context to the front.
  • would leave room for things like development:redis:seed

note - mentioned this in slack already, adding here for posterity

@JoelQ
Copy link
Contributor

JoelQ commented Mar 18, 2025

Does this rename blur what seeds actually are? I guess everyone is already confused about the distinction between dev data and seeds. Maybe this is an "if you can't beat them, join them" solution?

@stevepolitodesign
Copy link
Contributor Author

Does this rename blur what seeds actually are? I guess everyone is already confused about the distinction between dev data and seeds. Maybe this is an "if you can't beat them, join them" solution?

I personally think it's more clear than dev:prime. And, if we use the suggestion made by @vburzynski, it will read development:db:seed which I think is even more clear than my proposal.

I just can't think of the better name for what we're doing other than "seed".

@vburzynski
Copy link
Contributor

I think it's fine to use seed here. In general "seeding" a database is just populating it with some set of data. The conventions for the specific Ruby on Rails db:seed task are to use it for seeding the database with data needed for the application to run in any environment. Which suggests that the are other sets of seed data that may be required for applications to run in specific environments or even in specific contexts. They're all still an act of seeding, just not the primary db:seed

I could also see other variants working as well:

  • db:seed:development
    • db is the primary object we're acting upon
    • seed is the action
    • development is a targeting modifier in this naming scheme
  • development:db:seed
    • development here is used a prepended namespace or context
    • db is once again the primary object we're acting upon
    • seed is the action
    • this might make sense if there were additional rake tasks scoped to and specific to the development environment
  • db:development:seed
    • I don't know if I like this one, but included it for completeness. 🙃
  • or even db:seed:with_development
    • this would stray from the current implementation but takes a cue from data-migrate which extends db:migrate with the option db:migrate:with_data
    • it's even more clear that this is a modifier; but in this case one that extends the original. I'd expect this to run both the normal seed and the seed data specific to development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants