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