Module: Devise::Oauth2TokenBearerAuthenticatable::Schema

Defined in:
lib/devise_oauth2_token_bearer_authenticatable/schema.rb

Class Method Summary collapse

Class Method Details

.down(migration) ⇒ Object



46
47
48
49
50
# File 'lib/devise_oauth2_token_bearer_authenticatable/schema.rb', line 46

def self.down(migration)
  migration.drop_table :refresh_tokens
  migration.drop_table :access_tokens
  migration.drop_table :clients
end

.up(migration) ⇒ Object



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
35
36
37
38
39
40
41
42
43
44
# File 'lib/devise_oauth2_token_bearer_authenticatable/schema.rb', line 6

def self.up(migration)
  migration.create_table :clients do |t|
    t.string :name
    t.string :redirect_uri
    t.string :website
    t.string :identifier
    t.string :secret
    t.timestamps
  end
  migration.add_index :clients, :identifier

  migration.create_table :access_tokens do |t|
    t.belongs_to :user, :client
    t.string :token
    t.datetime :expires_at
    t.timestamps
  end
  migration.add_index :access_tokens, :token
  migration.add_index :access_tokens, :expires_at

  migration.create_table :refresh_tokens do |t|
    t.belongs_to :user, :client
    t.string :token
    t.datetime :expires_at
    t.timestamps
  end
  migration.add_index :refresh_tokens, :token
  migration.add_index :refresh_tokens, :expires_at

  migration.create_table :authorization_codes do |t|
    t.belongs_to :user, :client
    t.string :token
    t.datetime :expires_at
    t.string :redirect_uri
    t.timestamps
  end
  migration.add_index :authorization_codes, :token
  migration.add_index :authorization_codes, :expires_at
end