Sha256: 553c837212af9dfaf16130289746818f7932dff772ff15ae9d6a4c5f3e84ca51

Contents?: true

Size: 1.66 KB

Versions: 72

Compression:

Stored size: 1.66 KB

Contents

Sequel.migration do
  up do
    # The latest verification id for each consumer version tag
    create_view(:latest_verification_ids_for_consumer_and_provider,
      "select
        pv.pacticipant_id as provider_id,
        lpp.consumer_id,
        max(v.id) as latest_verification_id
      from verifications v
      join latest_pact_publications_by_consumer_versions lpp
        on v.pact_version_id = lpp.pact_version_id
      join versions pv
        on v.provider_version_id = pv.id
      group by pv.pacticipant_id, lpp.consumer_id")

    # The most recent verification for each consumer/consumer version tag/provider
    latest_verifications = from(:verifications)
      .select(
        Sequel[:lv][:consumer_id],
        Sequel[:lv][:provider_id],
        Sequel[:pv][:sha].as(:pact_version_sha),
        Sequel[:prv][:number].as(:provider_version_number),
        Sequel[:prv][:order].as(:provider_version_order),
        )
      .select_append{ verifications.* }
      .join(:latest_verification_ids_for_consumer_and_provider,
        {
          Sequel[:verifications][:id] => Sequel[:lv][:latest_verification_id],
        }, { table_alias: :lv })
      .join(:versions,
        {
          Sequel[:verifications][:provider_version_id] => Sequel[:prv][:id]
        }, { table_alias: :prv })
      .join(:pact_versions,
        {
          Sequel[:verifications][:pact_version_id] => Sequel[:pv][:id]
        }, { table_alias: :pv })

    create_or_replace_view(:latest_verifications_for_consumer_and_provider, latest_verifications)
  end

  down do
    drop_view(:latest_verifications_for_consumer_and_provider)
    drop_view(:latest_verification_ids_for_consumer_and_provider)
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
pact_broker-2.55.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.54.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.53.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.52.2 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.52.1 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.52.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.51.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.50.1 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.50.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.49.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.48.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.47.1 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.47.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.46.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.45.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.44.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.43.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.42.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.41.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb
pact_broker-2.40.0 db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb