Forum: Ruby on Rails rake migration with transactions.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mathias Stjernström (Guest)
on 2006-02-14 18:03
(Received via mailing list)
Hi!
I use migrations to handle my database scheme and i put all actions
between a transaction block like this .

execute "BEGIN work;"
execute "CREATE TABLE table1 (xxx);"
execute "CREATE TABLE table2 (xxx);"
execute "CREATE TABLE table3 (xxx);"
execute "COMMIT work;"

I do this because if 'create table2' fails, the process is aborted
but table 1 is still created.

Are there an easier way of doing this,
do i miss something obvious in migrations that does this by default?

Cheers!

Mathias
Stjernström
This topic is locked and can not be replied to.