Sha256: 8f5965a1ece1327eb27b716d058f7885c65df8e074e7dc85cf6eead3a7bb1bc0

Contents?: true

Size: 926 Bytes

Versions: 4

Compression:

Stored size: 926 Bytes

Contents

# This migration comes from spree (originally 20091015153048)
class AddOpenidFieldToUsers < ActiveRecord::Migration
  def up
    add_column :users, :openid_identifier, :string
    add_index :users, :openid_identifier

    change_column :users, :login, :string, :default => nil, :null => true
    change_column :users, :crypted_password, :string, :default => nil, :null => true
    change_column :users, :salt, :string, :default => nil, :null => true
  end

  def down
    remove_column :users, :openid_identifier

    # Due to namespacing change, temporarily set the table back to users
    Spree::User.table_name = 'users'

    [:login, :crypted_password, :salt].each do |field|
      Spree::User.where(field => nil).each { |user| user.update_column(field, '') if user.send(field).nil? }
      change_column :users, field, :string, :default => '', :null => false
    end

    Spree::User.table_name = 'spree_users'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datashift_spree-0.3.0 spec/sandbox/db/migrate/20121023154365_add_openid_field_to_users.spree.rb
datashift_spree-0.2.1 spec/sandbox/db/migrate/20121015151158_add_openid_field_to_users.spree.rb
datashift_spree-0.2.0 spec/sandbox/db/migrate/20120925192726_add_openid_field_to_users.spree.rb
datashift_spree-0.1.0 spec/sandbox/db/migrate/20120918081457_add_openid_field_to_users.spree.rb