pull/6827/head
parent
5aeb056b6c
commit
81c0d3de36
@ -1,30 +1,9 @@ |
|||||||
class FixPositions < ActiveRecord::Migration |
class FixPositions < ActiveRecord::Migration |
||||||
def self.up |
def self.up |
||||||
errors = [] |
#no longer necessary and did only set a default position |
||||||
Issue.find(:all, :conditions => "subject is NULL or (start_date is null and not due_date is null) or start_date > due_date or updated_on < created_on or start_date > created_on").each do |issue| |
|
||||||
errors << issue.id |
|
||||||
end |
|
||||||
|
|
||||||
if errors.size > 0 |
|
||||||
puts "You have issues in your database that have one or more of the following problems:" |
|
||||||
puts "* subject is missing" |
|
||||||
puts "* due date is set, but start dat is not" |
|
||||||
puts "* start date is later than due date" |
|
||||||
puts "* updated-date is before created-date" |
|
||||||
puts "* start date is after created-date" |
|
||||||
puts errors.inspect |
|
||||||
raise "Please fix these and retry the migration" |
|
||||||
end |
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do |
|
||||||
Story.find(:all, :conditions => "parent_id is NULL", :order => "project_id ASC, fixed_version_id ASC, position ASC").each_with_index do |s,i| |
|
||||||
s.position=i+1 |
|
||||||
s.save! |
|
||||||
end |
|
||||||
end |
|
||||||
end |
end |
||||||
|
|
||||||
def self.down |
def self.down |
||||||
raise ActiveRecord::IrreversibleMigration |
#pass |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -1,21 +1,9 @@ |
|||||||
class OrderTasksUsingTree < ActiveRecord::Migration |
class OrderTasksUsingTree < ActiveRecord::Migration |
||||||
def self.up |
def self.up |
||||||
last_task = {} |
#no longer necessary and did only set a default position |
||||||
ActiveRecord::Base.transaction do |
|
||||||
Task.find(:all, :conditions => "not parent_id is NULL", :order => "project_id ASC, parent_id ASC, position ASC").each do |t| |
|
||||||
begin |
|
||||||
t.move_after last_task[t.parent_id] if last_task[t.parent_id] |
|
||||||
rescue |
|
||||||
# nested tasks break this migrations. Task order not that |
|
||||||
# big a deal, proceed |
|
||||||
end |
|
||||||
|
|
||||||
last_task[t.parent_id] = t.id |
|
||||||
end |
|
||||||
end |
|
||||||
end |
end |
||||||
|
|
||||||
def self.down |
def self.down |
||||||
raise ActiveRecord::IrreversibleMigration |
#pass |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -1,16 +1,9 @@ |
|||||||
class RemoveTaskPosition < ActiveRecord::Migration |
class RemoveTaskPosition < ActiveRecord::Migration |
||||||
def self.up |
def self.up |
||||||
ActiveRecord::Base.transaction do |
#no longer necessary and did only correct position on tasks |
||||||
# this intentionally loads tasks as stories so we can issue |
|
||||||
# remove_from_list, which does more than just nilling the |
|
||||||
# position |
|
||||||
Story.find(:all, :conditions => "id <> root_id and not position is null").each do |t| |
|
||||||
t.remove_from_list |
|
||||||
end |
|
||||||
end |
|
||||||
end |
end |
||||||
|
|
||||||
def self.down |
def self.down |
||||||
raise ActiveRecord::IrreversibleMigration |
#pass |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -1,14 +1,9 @@ |
|||||||
class FixStoryPositionsAgain < ActiveRecord::Migration |
class FixStoryPositionsAgain < ActiveRecord::Migration |
||||||
def self.up |
def self.up |
||||||
ActiveRecord::Base.transaction do |
#no longer necessary and did only set a default position |
||||||
Story.find(:all, :conditions => "parent_id is NULL", :order => "project_id ASC, fixed_version_id ASC, position ASC").each_with_index do |s,i| |
|
||||||
s.position=i+1 |
|
||||||
s.save! |
|
||||||
end |
|
||||||
end |
|
||||||
end |
end |
||||||
|
|
||||||
def self.down |
def self.down |
||||||
raise ActiveRecord::IrreversibleMigration |
#pass |
||||||
end |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue