Class: CreateCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/authpwn_rails/generators/templates/003_create_credentials.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
# File 'lib/authpwn_rails/generators/templates/003_create_credentials.rb', line 2

def change
  create_table :credentials do |t|
    t.references :user, null: false, index: false, foreign_key: true
    t.string :type, limit: 32, null: false
    t.string :name, limit: 128, null: true

    t.timestamp :updated_at, null: false

    t.binary :key, limit: 2.kilobytes, null: true

    # All the credentials (maybe of a specific type) belonging to a user.
    t.index [:user_id, :type], unique: false
    # A specific credential, to find out what user it belongs to.
    t.index [:type, :name], unique: true
    # Expired credentials (particularly useful for tokens).
    t.index [:type, :updated_at], unique: false
  end
end