]> git.openstreetmap.org Git - rails.git/blob - db/migrate/040_create_oauth_tables.rb
Merge branch 'master' into terms
[rails.git] / db / migrate / 040_create_oauth_tables.rb
1 class CreateOauthTables < ActiveRecord::Migration
2   def self.up
3     create_table :client_applications do |t|
4       t.string :name
5       t.string :url
6       t.string :support_url
7       t.string :callback_url
8       t.string :key, :limit => 50
9       t.string :secret, :limit => 50
10       t.integer :user_id
11
12       t.timestamps
13     end
14     add_index :client_applications, :key, :unique => true
15     
16     create_table :oauth_tokens do |t|
17       t.integer :user_id
18       t.string :type, :limit => 20
19       t.integer :client_application_id
20       t.string :token, :limit => 50
21       t.string :secret, :limit => 50
22       t.timestamp :authorized_at, :invalidated_at
23       t.timestamps
24     end
25     
26     add_index :oauth_tokens, :token, :unique => true
27     
28     create_table :oauth_nonces do |t|
29       t.string :nonce
30       t.integer :timestamp
31
32       t.timestamps
33     end
34     add_index :oauth_nonces, [:nonce, :timestamp], :unique => true
35     
36   end
37
38   def self.down
39     drop_table :client_applications
40     drop_table :oauth_tokens
41     drop_table :oauth_nonces
42   end
43
44 end