Class: CreateOauthTables

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/active_record/oauth_provider_templates/migration.rb

Class Method Summary collapse

Class Method Details

.downObject



41
42
43
44
45
# File 'lib/generators/active_record/oauth_provider_templates/migration.rb', line 41

def self.down
  drop_table :client_applications
  drop_table :oauth_tokens
  drop_table :oauth_nonces
end

.upObject



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
35
36
37
38
39
# File 'lib/generators/active_record/oauth_provider_templates/migration.rb', line 2

def self.up
  create_table :client_applications do |t|
    t.string :name
    t.string :url
    t.string :support_url
    t.string :callback_url
    t.string :key, :limit => 40
    t.string :secret, :limit => 40
    t.integer :user_id

    t.timestamps
  end
  add_index :client_applications, :key, :unique => true

  create_table :oauth_tokens do |t|
    t.integer :user_id
    t.string :type, :limit => 20
    t.integer :client_application_id
    t.string :token, :limit => 40
    t.string :secret, :limit => 40
    t.string :callback_url
    t.string :verifier, :limit => 20
    t.string :scope
    t.timestamp :authorized_at, :invalidated_at, :expires_at
    t.timestamps
  end

  add_index :oauth_tokens, :token, :unique => true

  create_table :oauth_nonces do |t|
    t.string :nonce
    t.integer :timestamp

    t.timestamps
  end
  add_index :oauth_nonces,[:nonce, :timestamp], :unique => true

end