Capistrano before and after tasks

I try to extend db:test:copy_structure task to poulate test database
with some existing data everytime i run it.

It seems that “after_” task is not called as should be:

namespace :db do
namespace :test do
task :after_clone_structure do
puts “after_clone_structure_to_test”
end
end
end

Anyone know what I am doing wrong?
thanks in advance,
Bojan M.


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
-> tools, scripts, tricks from our code lab: http://source.mihelac.org

Bojan M. wrote:

end
end

Anyone know what I am doing wrong?
thanks in advance,
Bojan M.

Well, db:test:copy_structure is normal Rake task and not Capistrano
task, so that’s the reason why it doesn’t work.
The working code for loading data from file in MySql test database would
be:

namespace :db do
namespace :test do
task :load_data => :environment do
abcs = ActiveRecord::Base.configurations
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.connection.execute('SET foreign_key_checks =
')
IO.readlines(“db/data.sql”).join.split("\n\n").each do |table|
ActiveRecord::Base.connection.execute(table)
end
end
end
end

rake db:test:load_data

Hope it helps anyone.


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
-> tools, scripts, tricks from our code lab: http://source.mihelac.org

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs