-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Description
When running rails db:prepare
, if a DB is created, then the seeds will be run.
This is a problem when the DB being created is for something such as SolidCache (and likely SolidQueue, but I don't use that). A production environment that is functionnal can end up having its seed run again, which can cause all kind of issues, just because SolidCache was added.
If things are configured right, then re-running the whole thing will then work, because then no DB will be created so the seed will not be run... If things are not configured right, then the now existing DB might not contain a schema_migrations table, which means the seed will be run again.
This later case happens to me right now because of this issue: rails/solid_cache#228. But if I change my schema config temporarily, I confirmed that it worked the 2nd time I ran rails db:prepare
.
I believe the problem comes from https://github.com/rails/rails/blame/main/activerecord/lib/active_record/tasks/database_tasks.rb#L183, since any database being initialized means running the seed, which is likely not desired.
Rails version: 8.0.0.beta1
Ruby version: 3.3.5
SolidCache version: 1.0.6
The same problem would likely happen with SolidQueue and SolidCable too.