To help Rails to make inroads into corporate environments by sneaking under
the radar, it would be great Rails could use Oracle databases without
having to make any modifications of the db, such as adding synonyms,
otherwise the DBA gets involved and may ask more questions than you’d like
So anything to use a schema would help a lot.
We’ve been using Rails on an Oracle database (and on Postgres) since
before RubyConf and we’re not currently using any sort of synonyms, etc.
Our DBAs set up a development schema, a production schema, and N testing
schemas (1 for each developer, one for nightly demo builds, one for
continuous integration builds). I’m not a DBA so perhaps I’m missing a
salient detail, but after removing the troublesome synonyms we haven’t
had any problems in this configuration.
Here’s our database.yml file (with some names changed to protect the
guilty):
<%
determine our database user name from an environment variable
user = (ENV[‘PHOENIX_USER’] || ENV[‘LOGNAME’] || ENV[‘USERNAME’])
puts “User [#{user}]”
determine which database we are connecting to via an environment
variable
case ENV[‘PHOENIX_DB’]
when ‘oracle’ # connecting to an Oracle database
puts “Using Oracle”
%>
production:
adapter: oci
host: CNPROD
username: unknown
password: unknown
test:
adapter: oci
host: CNVOL
username: <%= user ? user : ‘cnet’ %>
password: XXXXXXXX
development:
adapter: oci
host: CNDEV
username: cnet
password: cnet
<%
else # connecting to a PostgreSQL database
%>
production:
adapter: postgresql
database: centernet
host: dbhost
username: centernet
password: XXXXXXXXX
test:
adapter: postgresql
database: rewrite_<%= user ? “#{user}_” : ‘’ %>vol
host: dbhost
username: centernet
password: XXXXXXXX
development:
adapter: postgresql
database: rewrite
host: dbhost
username: centernet
password: XXXXXXXXX
<% end %>
(Yes, I’m going to make another pass through there and merge some of the
commonalities between rules).
So, by default we’re using Postgres, but we can use Oracle by setting an
environment variable (PHOENIX_DB=oracle).
In the Oracle environment, each login has its own schema, so everyone’s
got an isolated space for test_unit/test_functional.
Again, maybe there’s some voodoo they pulled on the back-end that I’m
not clear on, but I don’t know of anything at the moment.
Rick
http://www.rickbradley.com MUPRN: 156
| it is based on
random email haiku | the Prism2 chipset, then it
| is compatible.