denniss
denniss

Reputation: 17589

Using two different DB (MySQL and Postgres) for a single Rails App

I have a rails app that uses MySQL for authentication and storing models. I currently am thinking of using PostgreSQL for analytics (by taking advantage of its special data types like arrays and KV pairs). I am just wondering how I would be able to have two types of databases (1 for models and authentication and 1 for analytics) when trying to save records using ActiveRecord. I want to save the model for analytics in Postgres and other models in MySQL.

Upvotes: 1

Views: 264

Answers (1)

jbarket
jbarket

Reputation: 882

My advice would be to migrate completely to PostgresSQL if you want to use it for anything. It'll make your life a lot simpler.

I believe your best answer otherwise will be to stop inheriting from ActiveRecord::Base for your models here. Instead include ActiveRecord, and manually call establish_connection.

But yeah, just migrate to PG. It'll save a lot of trouble.

Upvotes: 3

Related Questions