Sha256: 3cef4a009a003440425b60003e0ec7fdc97f9b48a91ff8455ba5120ca647e4f7

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true
# This migration comes from solidus_auth (originally 20190125170630)

class AddResetPasswordTokenIndexToSpreeUsers < SolidusSupport::Migration[4.2]
  # We're not using the standard Rails index name because somebody could have
  #  already added that index to the table. By using a custom name we ensure
  # that the index can effectively be added and removed via migrations/rollbacks
  #  without having any impact on such installations. The index name is Rails
  # standard name + "_solidus_auth_devise"; the length is 61 chars which is
  # still OK for Sqlite, mySQL and Postgres.
  def custom_index_name
    'index_spree_users_on_reset_password_token_solidus_auth_devise'
  end

  def default_index_exists?
    index_exists?(:spree_users, :reset_password_token)
  end

  def custom_index_exists?
    index_exists?(:spree_users, :reset_password_token, name: custom_index_name)
  end

  def up
    Spree::User.reset_column_information
    if Spree::User.column_names.include?('reset_password_token') && !default_index_exists? && !custom_index_exists?
      add_index :spree_users, :reset_password_token, unique: true, name: custom_index_name
    end
  end

  def down
    if custom_index_exists?
      remove_index :spree_users, name: custom_index_name
    end
  end
end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
solidus_auth_devise-2.5.4 spec/dummy/db/migrate/20211112052482_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_reports-1.0.0 spec/dummy/db/migrate/20211108200444_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_auth_devise-2.5.3 spec/dummy/db/migrate/20210129115393_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_auth_devise-2.5.2 spec/dummy/db/migrate/20201006131582_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_auth_devise-2.5.1 spec/dummy/db/migrate/20201006131582_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_auth_devise-2.5.0 spec/dummy/db/migrate/20201006131582_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_reviews-1.4.1 spec/dummy/db/migrate/20200810122148_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_billing_address-0.0.7 spec/dummy/db/migrate/20191128105378_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_billing_address-0.0.6 spec/dummy/db/migrate/20191122155277_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_drip-0.1.0 spec/dummy/db/migrate/20191101230344_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_drip-0.0.1 spec/dummy/db/migrate/20191101230344_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_billing_address-0.0.5 spec/dummy/db/migrate/20191028084790_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_billing_address-0.0.4 spec/dummy/db/migrate/20190926134981_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_billing_address-0.0.3 spec/dummy/db/migrate/20190924075675_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_billing_address-0.0.2 spec/dummy/db/migrate/20190920154665_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_billing_address-0.0.1 spec/dummy/db/migrate/20190823131041_add_reset_password_token_index_to_spree_users.solidus_auth.rb
solidus_bank_transfer-0.1.0 spec/dummy/db/migrate/20190822093474_add_reset_password_token_index_to_spree_users.solidus_auth.rb