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
...
Rpj
  • 5,348
  • 16
  • 62
  • 122
  • 1
    https://stackoverflow.com/questions/1825844/multiple-databases-in-rails – 7urkm3n Dec 13 '18 at 15:47
  • 1
    Possible duplicate of [Multiple databases in Rails](https://stackoverflow.com/questions/1825844/multiple-databases-in-rails) – 7urkm3n Dec 13 '18 at 15:47

0 Answers0