Commit 973008b5 authored by jplang's avatar jplang

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

git-svn-id: e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 0c9a62fb
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 < id) + 1")
def self.down
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment