Hi, How could I disable my database FOREIGN KEYs in a Rake task? Or, how could I call the execute() method in a Rake task? I''m trying to perform something like: task :delete_the_cippalippa => :environment do require RAILS_ROOT+''/lib/marsian.rb'' # FIXME: execute() is undefined execute "SET FOREIGN_KEY_CHECKS = 0" Cippalippa.delete(-1) [..some more code..] # FIXME: as above execute "SET FOREIGN_KEY_CHECKS = 1" end Thanks. Cheers, Marco
On May 8, 2006, at 5:54 PM, Marco Lazzeri wrote:> How could I disable my database FOREIGN KEYs in a Rake task? > Or, how could I call the execute() method in a Rake task? > > I''m trying to perform something like: > > task :delete_the_cippalippa => :environment do > require RAILS_ROOT+''/lib/marsian.rb'' > # FIXME: execute() is undefined > execute "SET FOREIGN_KEY_CHECKS = 0" > Cippalippa.delete(-1) > [..some more code..] > # FIXME: as above > execute "SET FOREIGN_KEY_CHECKS = 1" > endActiveRecord::Base.connection.execute ''...'' Cheers, jeremy
On 09/05/06, Jeremy Kemper <jeremy@bitsweat.net> wrote:> > How could I disable my database FOREIGN KEYs in a Rake task? > > Or, how could I call the execute() method in a Rake task? > > ActiveRecord::Base.connection.execute ''...''Thanks Jeremy. It works perfectly! Marco