#11: fixed migrations on Rails 3

This commit is contained in:
Anton Argirov 2015-05-29 19:46:55 +06:00
parent d230981dd7
commit 7c2f82c7fd
2 changed files with 1 additions and 31 deletions

View File

@ -1,30 +0,0 @@
class FixExampleWorkflow < ActiveRecord::Migration
def self.up
if workflow = CustomWorkflow.find_by_name("Duration/Done Ratio/Status correlation")
workflow.before_save = <<EOS
if done_ratio_changed?
if done_ratio==100 && status_id==2
self.status_id=3
elsif [1,3,4].include?(status_id) && done_ratio<100
self.status_id=2
end
end
if status_id_changed?
if status_id==2
self.start_date ||= Time.now
end
if status_id==3
self.done_ratio = 100
self.start_date ||= created_on
self.due_date ||= Time.now
end
end
EOS
workflow.save
end
end
def self.down
end
end

View File

@ -1,7 +1,7 @@
class CreateExampleWorkflow < ActiveRecord::Migration
def self.up
CustomWorkflow.reset_column_information
old = CustomWorkflow.find_by :name => 'Duration/Done Ratio/Status correlation'
old = CustomWorkflow.where(:name => 'Duration/Done Ratio/Status correlation').first
old.destroy if old
CustomWorkflow.create!(:name => 'Duration/Done Ratio/Status correlation', :author => 'anton.argirov@gmail.com', :description => <<EOD, :before_save => <<EOS)