Tuesday, July 15, 2008

reset_column_information in cruisecontrol.rb

As I described in a previous post, cruisecontrol.rb was failing with every other build because of the way our migrations were written (more on why they were written that way in a later post).

Today I was able to resolve the issue by adding a new task to our list of tasks that get run when cruise completes a build.


desc 'resets the column info for all models'
namespace :columns do
task :reset => :environment do
ActiveRecord::Base.reset_column_information
ActiveRecord::Base.send(:subclasses).each{|klass| klass.reset_column_information rescue nil}
end
end


Now, our cruise task looks like this:


task :cruise do
['test_env_init', 'db:rollback', 'columns:reset', 'db:migrate','test', 'spec:cruise:rcov'].each do |task|
Rake::Task[task].invoke
end
...


And cruisecontrol.rb is much happier...as is our development team!

No comments: