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:
parent
83deaad8e4
commit
eb15c9eaad
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue