From c85fe3872e519d83030d766321ece024bc3e2273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Fri, 29 May 2015 01:11:51 +0200 Subject: [PATCH] Replace DB environment variable with optional bundler groups See the changes to the changelog for more details --- .travis.yml | 6 +++--- Changelog.md | 14 ++++++++++++++ Gemfile | 10 ++++++---- Gemfile.lock | 5 +++++ config/database.yml.example | 22 ++++++++++------------ config/eye.rb | 2 +- script/ci/build.sh | 4 ++-- script/server | 5 ----- 8 files changed, 41 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a4e53d79..8f8a9134e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,9 @@ rvm: - 2.1 env: - - DB=postgres BUILD_TYPE=other + - DB=postgresql BUILD_TYPE=other - DB=mysql BUILD_TYPE=other - - DB=postgres BUILD_TYPE=cucumber + - DB=postgresql BUILD_TYPE=cucumber - DB=mysql BUILD_TYPE=cucumber sudo: false @@ -23,7 +23,7 @@ branches: - 'develop' before_install: gem install bundler -bundler_args: "--without development production heroku --jobs 3 --retry 3" +bundler_args: "--deployment --without development production --with mysql postgresql --jobs 3 --retry 3" script: "./script/ci/build.sh" diff --git a/Changelog.md b/Changelog.md index f8066b7d3..88529e448 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,19 @@ # 0.6.0.0 +## The DB environment variable is gone + +With Bundler 1.10 supporting optional groups, we removed the DB environment variable. When updating to this release, please update +bundler and select the database support you want: + +```sh +gem install bundler +bundle install --with mysql # For MySQL and MariaDB +bundle install --with postgresql # For PostgreSQL +``` + +For production setups we now additionally recommend adding the `--deployment` flag. +If you set the DB environment variable anywhere, that's no longer necessary. + ## Supported Ruby versions This release recommends using Ruby 2.2, while retaining Ruby 2.1 as an officially supported version. diff --git a/Gemfile b/Gemfile index 9bf54f75a..aed112db7 100644 --- a/Gemfile +++ b/Gemfile @@ -60,10 +60,12 @@ gem "autoprefixer-rails", "5.1.11" # Database -ENV["DB"] ||= "mysql" - -gem "mysql2", "0.3.18" if ENV["DB"] == "all" || ENV["DB"] == "mysql" -gem "pg", "0.18.1" if ENV["DB"] == "all" || ENV["DB"] == "postgres" +group :mysql, optional: true do + gem "mysql2", "0.3.18" +end +group :postgresql, optional: true do + gem "pg", "0.18.1" +end gem "activerecord-import", "0.7.0" diff --git a/Gemfile.lock b/Gemfile.lock index d48ab4f3a..aa78d13bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -463,6 +463,7 @@ GEM orm_adapter (0.5.0) parser (2.2.2.2) ast (>= 1.1, < 3.0) + pg (0.18.1) phantomjs (1.9.8.0) powerpack (0.1.1) pry (0.10.1) @@ -785,6 +786,7 @@ DEPENDENCIES omniauth-twitter (= 1.0.1) omniauth-wordpress (= 0.2.1) open_graph_reader (= 0.6.1) + pg (= 0.18.1) pry pry-byebug pry-debundle @@ -850,3 +852,6 @@ DEPENDENCIES uuid (= 2.3.7) webmock (= 1.21.0) will_paginate (= 3.0.7) + +BUNDLED WITH + 1.10.0 diff --git a/config/database.yml.example b/config/database.yml.example index f5a1e08cd..879572d36 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -1,3 +1,11 @@ +postgresql: &postgresql + adapter: postgresql + host: localhost + port: 5432 + username: postgres + password: + encoding: unicode + mysql: &mysql adapter: mysql2 host: "localhost" @@ -8,20 +16,13 @@ mysql: &mysql encoding: utf8mb4 collation: utf8mb4_bin -postgres: &postgres - adapter: postgresql - host: localhost - port: 5432 - username: postgres - password: - encoding: unicode # Comment the the mysql line and uncomment the postgres line # if you want to use postgres common: &common # Choose one of the following - <<: *mysql - #<<: *postgres + <<: *postgresql + #<<: *mysql # Should match environment.sidekiq.concurrency #pool: 25 @@ -32,9 +33,6 @@ common: &common # Normally you don't need to touch anything here -postgres_travis: &postgres_travis - adapter: postgresql - username: postgres combined: &combined <<: *common development: diff --git a/config/eye.rb b/config/eye.rb index 52d25aea4..2dc55f38b 100644 --- a/config/eye.rb +++ b/config/eye.rb @@ -7,7 +7,7 @@ end Eye.application("diaspora") do working_dir Rails.root.to_s - env "DB" => ENV["DB"], "RAILS_ENV" => rails_env + env "RAILS_ENV" => rails_env stdout "log/eye_processes_stdout.log" unless rails_env == "development" stderr "log/eye_processes_stderr.log" diff --git a/script/ci/build.sh b/script/ci/build.sh index 127874287..7a129f211 100755 --- a/script/ci/build.sh +++ b/script/ci/build.sh @@ -4,8 +4,8 @@ # Create a database.yml for the right database echo "Setting up database.yml for $DB" cp config/database.yml.example config/database.yml -if [ "$DB" = "postgres" ]; then - sed -i 's/*common/*postgres_travis/' config/database.yml +if [ "$DB" = "mysql" ]; then + sed -i 's/*common/*mysql/' config/database.yml fi command="bundle exec rake --trace ci:travis:${BUILD_TYPE}" diff --git a/script/server b/script/server index 0144e244f..2f63e2a64 100755 --- a/script/server +++ b/script/server @@ -113,11 +113,6 @@ vars=$(bin/bundle exec ruby ./script/get_config.rb \ on_failure "Couldn't parse config/diaspora.yml!" eval "$vars" -if [ -n "$DB" ] -then - export DB -fi - args="$@" for arg in $(echo $args | awk '{ for (i = 1; i <= NF; i++) print $i}') do