2007-01-31 23:57:01 +03:00
|
|
|
class AddRolePosition < ActiveRecord::Migration
|
|
|
|
def self.up
|
2007-10-23 01:07:13 +04:00
|
|
|
add_column :roles, :position, :integer, :default => 1
|
2011-12-10 21:06:46 +04:00
|
|
|
Role.update_all("position = (SELECT COUNT(*) FROM #{Role.table_name} r WHERE r.id < id) + 1")
|
2007-01-31 23:57:01 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
remove_column :roles, :position
|
|
|
|
end
|
|
|
|
end
|