zinc-collective / convene

An Operating System for the Solidarity Economy
https://convene.zinc.coop
Other
56 stars 19 forks source link

🧹 `rake db:seed` is idempotent #2320

Closed zspencer closed 1 month ago

zspencer commented 1 month ago

It turns out, running rails db:seed multiple times kept resulting in errors or duplicious data.

This makes it a bit easier to run multiple times, which can be helpful when making a change that also wants to update the seeds

zspencer commented 1 month ago

Hmm, I don't think I've used db:seeds:replant, mostly because the projects I've been on in the last half decade have relied (perhaps too) heavily on anonymized production data; rather than a seed file.

I can start working db:seeds:replant into my workflow and see if that gets me out of wanting them to be idempotent.

rosschapman commented 1 month ago

Interesting, I believe I agree with @anaulin here because I would expect to only run the primary seed on a clean database. However, I ok with the idea of having secondary seeds for setting up the app for a particular use case. Like rails db:seed:space:marketplace:ready that would act similar to factories in test setup. Although I don't feel like our app is complicated enough yet to warrant that. We find more bugs doing it all manually 😅