]> git.openstreetmap.org Git - rails.git/blob - db/migrate/053_add_open_id_authentication_tables.rb
Make OpenID authentication work with the latest plugin
[rails.git] / db / migrate / 053_add_open_id_authentication_tables.rb
1 class AddOpenIdAuthenticationTables < ActiveRecord::Migration
2   def self.up
3     create_table :open_id_authentication_associations, :force => true do |t|
4       t.integer :issued, :lifetime
5       t.string :handle, :assoc_type
6       t.binary :server_url, :secret
7     end
8
9     create_table :open_id_authentication_nonces, :force => true do |t|
10       t.integer :timestamp, :null => false
11       t.string :server_url, :null => true
12       t.string :salt, :null => false
13     end
14     
15     add_column :users, :openid_url, :string 
16
17     add_index :users, [:openid_url], :name => "user_openid_unique_idx", :unique => true
18     add_index :open_id_authentication_associations, [:server_url], :name => "open_id_associations_server_url_idx"
19     add_index :open_id_authentication_nonces, [:timestamp], :name => "open_id_nonces_timestamp_idx"
20   end
21
22   def self.down
23     remove_index :users, :name => "user_openid_unique_idx"
24     remove_index :open_id_authentication_associations, :name => "open_id_associations_server_url_idx"
25     remove_index :open_id_authentication_nonces, :name => "open_id_nonces_timestamp_idx"
26     remove_column :users, :openid_url
27     drop_table :open_id_authentication_associations
28     drop_table :open_id_authentication_nonces
29   end
30 end