-
Notifications
You must be signed in to change notification settings - Fork 11
/
migration_no_mapping.rb
29 lines (23 loc) · 1.31 KB
/
migration_no_mapping.rb
1
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
class AddAuthlogicRpxMigration < ActiveRecord::Migration
def self.up
add_column :<%= user_model_collection %>, :rpx_identifier, :string
add_index :<%= user_model_collection %>, :rpx_identifier
# == Customisation may be required here ==
# You may need to remove database constraints on other fields if they will be unused in the RPX case
# (e.g. crypted_password and password_salt to make password authentication optional).
# If you are using auto-registration, you must also remove any database constraints for fields that will be automatically mapped
# e.g.:
#change_column :<%= user_model_collection %>, :crypted_password, :string, :default => nil, :null => true
#change_column :<%= user_model_collection %>, :password_salt, :string, :default => nil, :null => true
end
def self.down
remove_column :<%= user_model_collection %>, :rpx_identifier
# == Customisation may be required here ==
# Restore user model database constraints as appropriate
# e.g.:
#[:crypted_password, :password_salt].each do |field|
# <%= user_model %>.all(:conditions => "#{field} is NULL").each { |user| user.update_attribute(field, "") if user.send(field).nil? }
# change_column :<%= user_model_collection %>, field, :string, :default => "", :null => false
#end
end
end