Migration in Multiple Database

hello to all
I been working on this from past few days.
.I am talking about separate migration for each one of the multiple
database that a single rails application has connection with.I know that
rails can work with multiple databases but what with migrations
for e.g
my main rails application has a connection to two databases
1> main_development
2> secondary_development

Know suppose i have to create a new migration for my secondary database
how do i do it

thanks to everyone

Virendra N. wrote:

my main rails application has a connection to two databases
1> main_development
2> secondary_development

Know suppose i have to create a new migration for my secondary database
how do i do it

I’ll trade you! This is how you do migrations. Change the declaration of
all of your applicable migrations:

class MyMigration < SecondaryDevelopmentMigration
… the remainder of your migration …

Put this somewhere convenient:

class SecondaryDevelopmentMigration < ActiveRecord::Migration
def self.connection
SecondaryDevelopment.connection
end
end

Your turn! How do you handle test fixtures for your second database?

Adam Ms. wrote:
[…]

Your turn! How do you handle test fixtures for your second database?

Test fixtures are evil. Use factories instead (I’m fond of Machinist
for this).

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Adam Ms. wrote:

Virendra N. wrote:

my main rails application has a connection to two databases
1> main_development
2> secondary_development

Know suppose i have to create a new migration for my secondary database
how do i do it

I’ll trade you! This is how you do migrations. Change the declaration of
all of your applicable migrations:

class MyMigration < SecondaryDevelopmentMigration
… the remainder of your migration …

Put this somewhere convenient:

class SecondaryDevelopmentMigration < ActiveRecord::Migration
def self.connection
SecondaryDevelopment.connection
end
end

Your turn! How do you handle test fixtures for your second database?

Sorry i didn’t get that could you please explain me one more time with
good e.g
thank anyway

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