Forum: Ruby on Rails Transactions and migrations (lots of records)???

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Philip H. (Guest)
on 2006-04-26 03:23
(Received via mailing list)
Hi all -

I know this must be really easy to do, but I can't for the life of me
figure it out.

I have about 100,000 rows I need to migrate over into rails using a

Right now, I select all of them out of the old database and do a series

new.col = old.col

Problem is each one is it's own transaction.  And it's slow.  I'd like
group them into sets of say 50-100 to speed things up a bit.

But the only example regarding transactions I can find are long the

   transaction do

Which doesn't really help me.

What I want to do is start a transaction before I start looping then
a counter and every 50th time, commit, then open another one.  Then have
final commit.

I'll deal with errors elsewhere... right now I just need it to go

I have a feeling I want begin_db_transaction and commit_db_transaction,
but I can't figure out how to use them in the way I want.

Help! :-)

This topic is locked and can not be replied to.