removing position setting migrations, keeping the migrations as such to make it transparent

pull/6827/head
Jens Ulferts 14 years ago
parent 5aeb056b6c
commit 81c0d3de36
  1. 13
      db/migrate/013_fill_position.rb
  2. 25
      db/migrate/014_fix_positions.rb
  3. 16
      db/migrate/015_order_tasks_using_tree.rb
  4. 11
      db/migrate/016_remove_task_position.rb
  5. 9
      db/migrate/018_fix_story_positions_again.rb

@ -1,17 +1,6 @@
class FillPosition < ActiveRecord::Migration class FillPosition < ActiveRecord::Migration
def self.up def self.up
pos = execute "select project_id, max(position) from issues where parent_id is null group by project_id" #no longer necessary and did only set a default position
pos.each do |row|
project_id = row[0].to_i
position = row[1].to_i
Story.find(:all, :conditions => ["project_id = ? and parent_id is null and position is null", project_id], :order => "created_on").each do |story|
position += 1
story.position = position
story.save
end
end
end end
def self.down def self.down

@ -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…
Cancel
Save