Tyler MacDonald wrote:
> I've taken to using this when I just want a migration to be a big wad of
> sql;
>
> runsplit.rb in my lib/ directory:
>
> class Runsplit < ActiveRecord::Migration
> def self.runsplit(sql)
> transaction do
> sql.split(';').each do |stmt|
> execute(stmt) if (stmt.strip! && stmt.length>0)
> end
> end
> end
> end
Why? Since (I think) Rails 2.2, all migrations are transactional
anyway, and for older versions of Rails, you can just use the
transactional_migrations plugin. This just seems to me like a waste of
effort.
In any case, if you have large amounts of raw SQL in migrations,
something is probably wrong. What are you trying to accomplish?
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---