Why you may ask? Because i have built the app on mysql and need to start using postgres for GIS component of my app only. Eventually i will migrate to postgres completely but in the mean time would like to know if this is possible
A:
You just have con instantiate another ODBC connection with your new Postgres driver an use it to create query's. That's all.
eLZahR
2009-10-28 08:43:46
+6
A:
If for instance you, in your database.yml have something like this (don't really recall the correct attributes, but I think you get the idea):
postgres:
adapter: postgres
database: gis
mysql:
adapter: mysql
database: app
Then, you could add
establish_connection :postgres
in the models that should use the Postgres database. Of course, it might be easier to create an abstract class and make all the models to use that one instead since that is more DRYer.
class PostgresRecord::Base < ActiveRecord::Base
self.abstract_class = true
establish_connection :postgres
end
Or, since you are planning on migrating to Postgres eventually, you probably should do the opposite, make the Postgres database default and change the connection for the MySQL.
Jimmy Stenke
2009-10-28 08:51:32
thanks Jimmy TipTop!
ADAM
2009-10-28 09:06:11