Skip to content

Rails: 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

Merged
merged 2 commits into from
Jun 6, 2025

Conversation

stevepolitodesign
Copy link
Contributor

@stevepolitodesign stevepolitodesign commented Mar 10, 2025

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.

We're already doing this in ChatBot.

https://github.com/thoughtbot/chat_bot/pull/52

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

@emilford
Copy link

emilford commented May 9, 2025

@stevepolitodesign what are your thoughts on @vburzynski's suggestions?

@stevepolitodesign stevepolitodesign force-pushed the sp-seeds branch 2 times, most recently from 115f83b to 04c1806 Compare May 9, 2025 19:11
@stevepolitodesign stevepolitodesign changed the title Update guidance on development environment seed data. Rails: Update guidance on development environment seed data. May 9, 2025
@stevepolitodesign
Copy link
Contributor Author

@emilford thank you for bumping this. I just addressed this, and wanted to highlight that we're doing this in ChatBot.

https://github.com/thoughtbot/chat_bot/pull/52

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.

We're already doing this in ChatBot.

thoughtbot/chat_bot#52

[1]: thoughtbot/suspenders#1251
@stevepolitodesign stevepolitodesign force-pushed the sp-seeds branch 2 times, most recently from 961661f to a132a30 Compare June 6, 2025 15:52
@stevepolitodesign stevepolitodesign merged commit 3f21788 into main Jun 6, 2025
2 checks passed
@stevepolitodesign stevepolitodesign deleted the sp-seeds branch June 6, 2025 19:18
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.

4 participants