OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/db/migrate/001_sti_for_roles.rb

26 lines
675 B

class StiForRoles < ActiveRecord::Migration
def self.up
add_column :roles, :type, :string, :limit => 30, :default => "Role"
Role.all.each do |role|
role.type = "Role"
role.save
end
create_table :principal_roles, :force => true do |t|
t.column :role_id, :integer, :null => false
t.column :principal_id, :integer, :null => false
t.timestamps
end
add_index :principal_roles, :role_id
add_index :principal_roles, :principal_id
end
def self.down
remove_column :roles, :type
remove_index :principal_roles, :role_id
remove_index :principal_roles, :principal_id
drop_table :principal_roles
end
end