mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-26 00:04:20 +00:00
#11: fixed migrations on Rails 3
This commit is contained in:
parent
d230981dd7
commit
7c2f82c7fd
@ -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
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
class CreateExampleWorkflow < ActiveRecord::Migration
|
class CreateExampleWorkflow < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
CustomWorkflow.reset_column_information
|
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
|
old.destroy if old
|
||||||
|
|
||||||
CustomWorkflow.create!(:name => 'Duration/Done Ratio/Status correlation', :author => 'anton.argirov@gmail.com', :description => <<EOD, :before_save => <<EOS)
|
CustomWorkflow.create!(:name => 'Duration/Done Ratio/Status correlation', :author => 'anton.argirov@gmail.com', :description => <<EOD, :before_save => <<EOS)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user