generating schema.rb file for two databases

Go To StackoverFlow.com

2

In my rails application I have two databases, I was able to get this up and running with following settings

database.yml

development: &defaults
  adapter: mysql
  encoding: utf8
  database: <Database1>
  username: <user_name>
  password: <password>
  host: localhost

second_development: &defaults
  adapter: mysql
  encoding: utf8
  database: <Database2>
  username: <user_name>
  password: <password>
  host: localhost

test: &defaults
  adapter: mysql
  encoding: utf8
  database: <Database1_test>
  username: <user_name>
  password: <password>
  host: localhost

second_test: &defaults
  adapter: mysql
  encoding: utf8
  database: <Database2_test>
  username: <user_name>
  password: <password>
  host: localhost

But the problem is when running the test cases, I'm using 'mocha', 'guard' and 'notahat-machinist', and when I try to run the test cases, it first runs the schema.rb file. But the problem is it creates the schema from the first test database only

test: &defaults
      adapter: mysql
      encoding: utf8
      database: <Database1_test>
      username: <user_name>
      password: <password>
      host: localhost 

this will makes the test related to the second test database 'Database2_test' fail. What would be the workaround for this.

to generate a schema.rb file which has both the database schema.

thanks in advance

2012-04-04 05:05
by sameera207
Why do you need to perform tests for the first testing environment and the second testing environment in one run of the testing framework - sarnold 2012-04-04 05:08
Hi @sarnold, thanks for the replay, my unit tests are spread across both the databases, so I need both the databases when running the unit test - sameera207 2012-04-04 11:34


0

The schema.rb generate is define by the connection. So you need use the good connection in your test to have the good schema.

2012-04-04 08:05
by shingara
Hi @Singara, thanks for the replay. Both my connections are working and my unit tests are spread across both the databases, so I need both the databases when running the unit test - sameera207 2012-04-04 11:33
Ads