-
Notifications
You must be signed in to change notification settings - Fork 126
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
fix: prevent duplicate configuration lines in production.rb #349
base: main
Are you sure you want to change the base?
Conversation
Why are you running the generator more than once? I mean, I think it would be nice for it to be idempotent, but we gotta find a simpler way to do that than what's proposed. |
This happens when upgrading from one version of another to generate new files added by newer versions. I guess once a stable version is out, it would not happen or if you never run the generator again. |
perhaps we can include both in the replacement string like this
|
I thought that was what we were already doing? Another option is just not to do a replacement if it's already set to solid_queue. |
Just to clarify the generator adds these two lines
but if generator runs again it ends adding another line because replacement string does not contain the whole thing
so this PR proposes to check separately whether I thought we could do all in a single replacement string (without +) but that still does not check if
will push this shortly. |
Hi DHH and @uurcank , I've encountered this issue as well while experimenting with Enlitenment and running their generators multiple times with different configurations. Initially, I didn't realize it was coming from Rails. I believe the solution using In any case, both solutions work fine for me as long as they are added. :) # Inject `config.solid_queue.connects_to` if not already present
unless File.read(production_rb). include?("config.solid_queue.connects_to")
inject_into_file production_rb,
"\n config.solid_queue.connects_to = { database: { writing: :queue } }",
after: /config\.active_job\.queue_adapter\s+=.*/
end Thanks! |
The generator was adding duplicate lines to production.rb each time it is run
This PR refactors the generator to: