Put each database adapter into its own group in your Gemfile
:
group :pg do
gem "pg"
end
group :mysql do
gem "mysql2"
end
When deploying, instruct bundler to install without the groups you do not need for the specific deployment:
bundle config set without mysql
bundle install