Sha256: 3f8c727fd337de733a464e87524a6d93a82633a0ca58f9462751049923e2f5ed

Contents?: true

Size: 1.97 KB

Versions: 22

Compression:

Stored size: 1.97 KB

Contents

Sequel.migration do
  up do
    # The latest verification id for each consumer version tag
    # This is not the latest verification for the latest pact with a given tag,
    # this is the latest verification for any pact with the tag
    create_view(:latest_verification_ids_for_consumer_version_tags,
      "select
        pv.pacticipant_id as provider_id,
        lpp.consumer_id,
        t.name as consumer_version_tag_name,
        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 tags t
        on lpp.consumer_version_id = t.version_id
      join versions pv
        on v.provider_version_id = pv.id
      group by pv.pacticipant_id, lpp.consumer_id, t.name")

    # 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[:lv][:consumer_version_tag_name],
        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_version_tags,
        {
          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_version_tags, latest_verifications)
  end

  down do
    drop_view(:latest_verifications_for_consumer_version_tags)
    drop_view(:latest_verification_ids_for_consumer_version_tags)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
pact_broker-2.39.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.38.1 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.38.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.37.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.36.1 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.36.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.35.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.34.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.33.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.32.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.31.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.30.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.29.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.27.6 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.27.5 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.27.4 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.27.3 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.27.2 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.27.0 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb
pact_broker-2.26.1 db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb