Nathan Leach
2007-Jun-07 15:10 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---