<commit_before>class FixIdentities < ActiveRecord::Migration
  def up
    new_provider = Gitlab.config.ldap.servers.first.last['provider_name']
	  # Delete duplicate identities
    Identity.connection.select_one("DELETE FROM identities WHERE provider = 'ldap' AND user_id IN (SELECT user_id FROM identities WHERE provider = '#{new_provider}')")
	  # Update legacy identities
    Identity.where(provider: 'ldap').update_all(provider: new_provider)

    if defined?(LdapGroupLink)
      LdapGroupLink.where('provider IS NULL').update_all(provider: new_provider)
    end
  end

  def down
  end
end<commit_msg>Change migration to SQL<commit_after>class FixIdentities < ActiveRecord::Migration
  def up
    new_provider = Gitlab.config.ldap.servers.first.last['provider_name']

	  # Delete duplicate identities
    execute "DELETE FROM identities WHERE provider = 'ldap' AND user_id IN (SELECT user_id FROM identities WHERE provider = '#{new_provider}')"

    # Update legacy identities
    execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap';"

    if defined?(LdapGroupLink)
      execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL;"
    end
  end

  def down
  end
end
{'fraction_non_alphanumeric': 0.09054163298302344, 'fraction_numerical': 0.0, 'mean_word_length': 4.601809954751131, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5515660', 'n_tokens_mistral': 359, 'n_tokens_neox': 349, 'n_words': 103}