020_add_role_position.rb 273 Bytes
Newer Older
1
class AddRolePosition < ActiveRecord::Migration[4.2]
2
  def self.up
3
    add_column :roles, :position, :integer, :default => 1
4
    Role.all.each_with_index {|role, i| role.update_attribute(:position, i+1)}
5 6 7 8 9 10
  end

  def self.down
    remove_column :roles, :position
  end
end