class PactBroker::DB::DataMigrations::SetContractDataUpdatedAtForIntegrations
Public Class Methods
Source
# File lib/pact_broker/db/data_migrations/set_contract_data_updated_at_for_integrations.rb, line 7 def self.call(connection) join = { Sequel[:integrations][:consumer_id] => Sequel[:target][:consumer_id], Sequel[:integrations][:provider_id] => Sequel[:target][:provider_id] } max_created_at_for_each_integration = integrations_max_created_at(connection).from_self(alias: :target).select(:created_at).where(join) connection[:integrations] .where(contract_data_updated_at: nil) .update(contract_data_updated_at: max_created_at_for_each_integration) end
Source
# File lib/pact_broker/db/data_migrations/set_contract_data_updated_at_for_integrations.rb, line 22 def self.integrations_max_created_at(connection) pact_publication_max_created_at(connection) .union(verification_max_created_at(connection)) .select_group(:consumer_id, :provider_id) .select_append{ max(:created_at).as(:created_at) } end
@return [Sequel::Dataset] the overall max created_at from the union of the pact_publications and verifications tables, for each integration keyed by consumer_id/provider_id
Source
# File lib/pact_broker/db/data_migrations/set_contract_data_updated_at_for_integrations.rb, line 31 def self.pact_publication_max_created_at(connection) connection[:pact_publications] .select_group(:consumer_id, :provider_id) .select_append{ max(:created_at).as(:created_at) } end
@return [Sequel::Dataset] the max created_at from the pact_publications table for each integration keyed by consumer_id/provider_id
Source
# File lib/pact_broker/db/data_migrations/set_contract_data_updated_at_for_integrations.rb, line 39 def self.verification_max_created_at(connection) connection[:verifications] .select_group(:consumer_id, :provider_id) .select_append{ max(:created_at).as(:created_at) } end
@return [Sequel::Dataset] the max created_at from the verifications table for each integration keyed by consumer_id/provider_id