daya
August 17, 2006, 5:23pm
1
Hi All
I am trying to understand if I can use migrations to migrate data under
the
following conditions
Across 2 different databases (Oracle/DB2) with same schemas.
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
daya
August 17, 2006, 5:29pm
2
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
daya
August 17, 2006, 5:38pm
3
Thanks Jodi
I have been able to connect to multiple databases by specifying class
specific connections.
My questions a bit refined now are
what should I be doing in self.up and self.down, keeping in mind that
I
won’t have DDL access
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
daya
August 17, 2006, 5:59pm
4
Hey Daya,
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
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