<commit_before>module PactBroker
  module DB
    module DataMigrations
      class SetPacticipantIdsForVerifications
        def self.call connection
          if columns_exist?(connection)
            ids = connection.from(:verifications)
              .select(Sequel[:verifications][:id], Sequel[:pact_versions][:consumer_id], Sequel[:pact_versions][:provider_id])
              .join(:pact_versions, {id: :provider_version_id})
              .where(Sequel[:verifications][:consumer_id] => nil)
              .or(Sequel[:verifications][:provider_id] => nil)

            ids.each do | id |
              connection.from(:verifications).where(id: id[:id]).update(consumer_id: id[:consumer_id], provider_id: id[:provider_id])
            end
          end
        end

        def self.columns_exist?(connection)
          column_exists?(connection, :verifications, :provider_id) &&
            column_exists?(connection, :verifications, :consumer_id) &&
            column_exists?(connection, :verifications, :provider_version_id) &&
            column_exists?(connection, :pact_versions, :provider_id) &&
            column_exists?(connection, :pact_versions, :consumer_id) &&
            column_exists?(connection, :pact_versions, :id)<commit_msg>chore: fix join column name for setting pacticipant ids for verifications<commit_after>module PactBroker
  module DB
    module DataMigrations
      class SetPacticipantIdsForVerifications
        def self.call connection
          if columns_exist?(connection)
            ids = connection.from(:verifications)
              .select(Sequel[:verifications][:id], Sequel[:pact_versions][:consumer_id], Sequel[:pact_versions][:provider_id])
              .join(:pact_versions, {id: :pact_version_id})
              .where(Sequel[:verifications][:consumer_id] => nil)
              .or(Sequel[:verifications][:provider_id] => nil)

            ids.each do | id |
              connection.from(:verifications).where(id: id[:id]).update(consumer_id: id[:consumer_id], provider_id: id[:provider_id])
            end
          end
        end

        def self.columns_exist?(connection)
          column_exists?(connection, :verifications, :provider_id) &&
            column_exists?(connection, :verifications, :consumer_id) &&
            column_exists?(connection, :verifications, :provider_version_id) &&
            column_exists?(connection, :pact_versions, :provider_id) &&
            column_exists?(connection, :pact_versions, :consumer_id) &&
            column_exists?(connection, :pact_versions, :id)
{'fraction_non_alphanumeric': 0.11619718309859155, 'fraction_numerical': 0.0, 'mean_word_length': 3.05229793977813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5398319', 'n_tokens_mistral': 718, 'n_tokens_neox': 715, 'n_words': 121}