class CreateAdminRoles < ActiveRecord::Migration
  def change
    create_table :admin_roles do |t|
      t.string :name,       :null => false
      t.text :description
    end
    create_table :admin_roles_admin_users do |t|
      t.integer :admin_role_id
      t.integer :admin_user_id
    end
    create_table :admin_permissions_admin_roles do |t|
      t.integer :admin_role_id
      t.integer :admin_permission_id
    end
    add_index :admin_roles_admin_users,
              [:admin_role_id, :admin_user_id],
              :name => "idx_admin_r_u_id"
    add_index :admin_permissions_admin_roles,
              [:admin_role_id, :admin_permission_id],
              :name => "idx_admin_roles_id"
  end
end
