Class: CreateUsers

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/authorizme/templates/migrations/1_create_users.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/authorizme/templates/migrations/1_create_users.rb', line 2

def change
  create_table :users do |t|
    # References to user role and user origin provider
    t.references :user_role
    t.integer :origin_provider_id
    
    # Required attributes for user
    t.string :first_name
    t.string :last_name
    t.string :email
    t.string :image_url
    t.boolean :has_provider, :null => false, :default => false

    # For password
    t.string :password_digest
    
    # For reseting password
    t.string :password_reset_token
    t.datetime :password_reset_sent_at

    # Extending with your own data for user
    # here

    t.timestamps
  end

  # Indices
  change_table :users do |t|
    t.index :email, :unique => true
    t.index :user_role_id
    t.index :origin_provider_id
  end
end