Sha256: 15605d3fb0026626cee7a7642eee9de7d45e33cdadde74a7c3c5d3effb38588e

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

class CreateUserRoles < ActiveRecord::Migration
  def self.up
    create_table :user_roles do |t|
      t.column :user_id, :integer, :null => false
      t.column :role_id, :integer, :null => false
      t.timestamps
    end

    # Add foreign keys
    add_foreign_key :user_roles, :users, :column => "user_id"
    add_foreign_key :user_roles, :roles, :column => "role_id"

    # Create indexes
    add_index :user_roles, [:user_id, :role_id], :unique
  end

  def self.down
    drop_table :user_roles
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
role_based_security-0.5.0 lib/generators/role_based_security/templates/20110510155626_create_user_roles.rb