Skip to content

Commit

Permalink
Don't add solid_queue.connects_to configuration more than once
Browse files Browse the repository at this point in the history
Or, in other words, make the install generator idempotent.

Inspired by #349
  • Loading branch information
rosa committed Dec 3, 2024
1 parent 2e9eab1 commit 76b7eaf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/generators/solid_queue/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ def copy_files
chmod "bin/jobs", 0755 & ~File.umask, verbose: false
end

def configure_active_job_adapter
gsub_file Pathname(destination_root).join("config/environments/production.rb"),
/(# )?config\.active_job\.queue_adapter\s+=.*/,
def configure_adapter_and_database
pathname = Pathname(destination_root).join("config/environments/production.rb")

gsub_file pathname, /\n\s*config\.solid_queue\.connects_to\s+=.*\n/, "\n", verbose: false
gsub_file pathname, /(# )?config\.active_job\.queue_adapter\s+=.*\n/,
"config.active_job.queue_adapter = :solid_queue\n" +
" config.solid_queue.connects_to = { database: { writing: :queue } }\n"
end
Expand Down

0 comments on commit 76b7eaf

Please sign in to comment.