I want to require capistrano/postgresql
only if stage is not production.
However, this Capfile always require capistrano/postgresql
because fetch(:stage)
is empty.
( puts fetch(:stage) || "no stage"
in Capfile prints "no stage")
require 'capistrano/bundler'
require 'capistrano/npm'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/puma'
require 'capistrano/puma/nginx'
require 'capistrano/postgresql' unless fetch(:stage) == "production"
require 'capistrano/secrets_yml'
Should I put require 'capistrano/postgresql'
in config/deploy/staging.rb etc.. (I don't know whether it works or not)?
Or is there any other concise way?
EDIT
If I put require 'capistrano/postgresql'
in config/deploy/staging.rb, the following error appears.
WARNING: load:defaults has already been invoked and can no longer be modified.
Check that you haven't loaded a Capistrano plugin in deploy.rb by mistake.
Plugins must be loaded in the Capfile to initialize properly.
(Backtrace restricted to imported tasks)
cap aborted!
can't modify frozen #<Class:#<Rake::Task:0x007fd8bcd22868>>