Migrations for migrating data across databases - is it possi

Hi All

I am trying to understand if I can use migrations to migrate data under
the
following conditions

  1. Across 2 different databases (Oracle/DB2) with same schemas.
  2. Across 2 different databases (Oracle/DB2) with different schemas.

I am trying to avoid writing DBI/OCI8 scripts.

Can somone please shed some light if this is even possible?

thanks
-daya

Hey Daya -

You’ve got a couple of challenges - one is talking to multiple
databases.

This article will help you slay that dragon:
http://programmerassist.com/article/302

You’ll note a reference to the ActiveRecord/Base documentation.

Plus (in a previous email) I think you mentioned not being able to
execute DDL? if so, tables (etc) will be created by your DBA, and
your migration scripts will utter DML.

Hopefully that moves your forward.

cheers,
Jodi

Thanks Jodi

I have been able to connect to multiple databases by specifying class
specific connections.

My questions a bit refined now are

  1. what should I be doing in self.up and self.down, keeping in mind that
    I
    won’t have DDL access
  2. should I be using one migration per table or can I use one migration
    for
    multiple tables?

I agree that most my question stem from my lack of deep understanding
about
migrations.

Regards
-daya

Hey Daya,

  1. what should I be doing in self.up and self.down, keeping in mind
    that I won’t have DDL access

Since you don’t have DDL access, then code your DML there. grin.

This can take the place of raw sql, or as I like to code them using
Model methods; ala:

class SeedFoosBars < ActiveRecord::Migration

class Foo < ActiveRecord::Base;
has_many :bars
end
class Bar < ActiveRecord::Base;
belongs_to :foo
end

def self.up

if you had DDL above then you’d need to

Foo.reset_column_information

foo = Foo.create(:description => “Foo description”)
Bar.create(:description => “Bar description”, :foo => foo)

end

def self.down
# here you’d remove the seeded data above
end

  1. should I be using one migration per table or can I use one
    migration for multiple tables?
This topic was recently discussed. I like to target migrations for

functionality(multiple tables) - others per table. Whatever floats
your boat!

	http://comments.gmane.org/gmane.comp.lang.ruby.rails/91032

Both AWDWR and the Recipes book will be of great value to you Daya
[ as well as the list archive and google].

cheers,
Jodi

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