Class: OAuth2::Model::Schema

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/oauth2/model/schema.rb

Class Method Summary collapse

Class Method Details

.downObject



34
35
36
37
# File 'lib/oauth2/model/schema.rb', line 34

def self.down
  drop_table :oauth2_clients
  drop_table :oauth2_authorizations
end

.upObject



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
# File 'lib/oauth2/model/schema.rb', line 5

def self.up
  create_table :oauth2_clients, :force => true do |t|
    t.timestamps
    t.string     :oauth2_client_owner_type
    t.integer    :oauth2_client_owner_id
    t.string     :name
    t.string     :client_id
    t.string     :client_secret_hash
    t.string     :redirect_uri
  end
  add_index :oauth2_clients, :client_id
  
  create_table :oauth2_authorizations, :force => true do |t|
    t.timestamps
    t.string     :oauth2_resource_owner_type
    t.integer    :oauth2_resource_owner_id
    t.belongs_to :client
    t.string     :scope
    t.string     :code,               :limit => 40
    t.string     :access_token_hash,  :limit => 40
    t.string     :refresh_token_hash, :limit => 40
    t.datetime   :expires_at
  end
  add_index :oauth2_authorizations, [:client_id, :code]
  add_index :oauth2_authorizations, [:access_token_hash]
  add_index :oauth2_authorizations, [:client_id, :access_token_hash]
  add_index :oauth2_authorizations, [:client_id, :refresh_token_hash]
end