How to use Postgres schemas in Rails app to separate data

Rails/Postgres Gurus,

Question:
Is it possible to use Postgres schemas within a Rails app to separate
tables
and data between two different apps?

Problem Set:
I am thinking of combining two apps. I want to share some data (certain
tables) between them, but I want the migrations and other activities to
be
separated. I don’t want any table changes in one app to impact the
other.

Example:
App 1 contains order entry. App 2 contains contact management. In App
2, I
want to access the order history for a customer/contact. So, I create
an
order model in App 2 and set the table name to include the schema…e.g.
set_table_name “schema1.orders”.

However, I want both apps to have their own migrations. How do I tell
Rails
to use a particular schema when doing migrations, fixture loads, etc.?

Alternative(s):
The other reasonable option seems to be multiple database connections in
each app, which I haven’t investigated much yet. I have read a little
about
the “magic” multi-connection stuff. I am just thinking the schema thing
in
Postgres might be a cleaner (read…easier for me) solution.

Any tips, alternatives, or berating on why not to pursue this would be
appreciated.

Thanks,
Nathan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs