I am deploying regular updates for my Rails application with Capistrano and I keep a version number as a string in a global constant.
I would like to be a able to deploy/run a simple script only once for a specific update, that will perform some operations on the database (I am using mongoid, and I have modified the schema a bit)
Let's say I am under version 0.1.25 and upgrading to 0.1.26, I'd like to run this custom script only once for servers that are 0.1.25 or below (the script won't be ran again for next updates like 0.1.26 to 0.1.27)
MyModel.all.each do |instance|
instance.new_field_with_v26 = somefunction
end
I believe this can be implemented as a Capistrano task, but how do I retrieve the previous value of that constant ? (Application::VERSION_NUMBER
)