0

How to configure rails project to work simultaneously across mysql, postgres databases. Gemfile expects both the database gems to be present. One of the developers is pointing to a MySQL database and another one to a Postgres database. How do I have a clear setup without having to modify the database.yml file or Gemfile.

config/database.yml
default: &default
  adapter: mysql2
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password: 
  host: localhost

default-pg: &default-pg
  adapter: postgresql
  encoding: unicode
  pool: 5
  username: 'root'
  password: 'password'
  host: 'localhost'
  port: 5432

development:
  # <<: *default
  <<: *default-pg
  database: devdb

Gemfile looks like this

..
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
gem 'pg'
..

Dockerfile looks like this

...
RUN apk add --no-cache \
  build-base \
  libxml2-dev \
  libxslt-dev \
  mysql-dev \
  postgresql-dev \
  ruby-nokogiri \ 
  nodejs
...
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.