OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/db/migrate/013_fill_position.rb

21 lines
541 B

class FillPosition < ActiveRecord::Migration
def self.up
pos = execute "select project_id, max(position) from issues where parent_id is null group by project_id"
pos.each do |row|
project_id = row[0].to_i
position = row[1].to_i
14 years ago
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
14 years ago
story.position = position
story.save
end
end
end
def self.down
#pass
end
end