Role.all broken in migration due to default sort (columns do not exist yet). Use raw SQL instead.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8182 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-12-10 17:06:46 +00:00
parent 83deaad8e4
commit eb15c9eaad
1 changed files with 1 additions and 1 deletions

View File

@ -1,7 +1,7 @@
class AddRolePosition < ActiveRecord::Migration
def self.up
add_column :roles, :position, :integer, :default => 1
Role.find(:all).each_with_index {|role, i| role.update_attribute(:position, i+1)}
Role.update_all("position = (SELECT COUNT(*) FROM #{Role.table_name} r WHERE r.id < id) + 1")
end
def self.down