Sha256: a049a8101ed31f76031d77f85a7264b9a2f8364b204f58697d0fdeeafb9a4005

Contents?: true

Size: 912 Bytes

Versions: 37

Compression:

Stored size: 912 Bytes

Contents

# In theory Devise will downcase emails when storing, but where data is migrated (and the
# database updated directly and not via Devise), duplicate email addreseses become possible if
# the case varies. It is this scenario we are keen to address.
class CreateCaseInsensitiveIndexOnPatients < ActiveRecord::Migration[5.2]
  def up
    within_renalware_schema do
      remove_index :users, :email
      remove_index :users, :username
      add_index :users, "lower(email)", unique: true, name: "index_users_on_lower_email"
      add_index :users, "lower(username)", unique: true, name: "index_users_on_lower_username"
    end
  end

  def down
    within_renalware_schema do
      remove_index :users, name: "index_users_on_lower_email"
      remove_index :users, name: "index_users_on_lower_username"
      add_index :users, :email, unique: true
      add_index :users, :username, unique: true
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
renalware-core-2.1.1 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.1.0 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.167 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.166 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.165 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.164 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.163 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.162 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.161 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.160 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.159 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.158 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.157 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.156 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.155 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.153 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.152 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.151 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.149 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb
renalware-core-2.0.148 db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb