Sha256: d5d5c42d12ac02a7bdf8fa34ae757e0f10f2852c16284c61ddb69cfbb6a81c7a

Contents?: true

Size: 1.21 KB

Versions: 171

Compression:

Stored size: 1.21 KB

Contents

Sequel.migration do
  change do
    create_view(:all_pacts,
      Sequel::Model.db[:pacts].select(Sequel[:pacts][:id], Sequel[:c][:id].as(:consumer_id), Sequel[:c][:name].as(:consumer_name),
      Sequel[:cv][:number].as(:consumer_version_number), Sequel[:cv][:order].as(:consumer_version_order),
      Sequel[:p][:id].as(:provider_id), Sequel[:p][:name].as(:provider_name),
      Sequel[:pacts][:json_content]).
      join(:versions, {:id => :version_id}, {:table_alias => :cv, implicit_qualifier: :pacts}).
      join(:pacticipants, {:id => :pacticipant_id}, {:table_alias => :c, implicit_qualifier: :cv}).
      join(:pacticipants, {:id => :provider_id}, {:table_alias => :p, implicit_qualifier: :pacts}))

    create_view(:latest_pact_consumer_version_orders,
      "select provider_id, consumer_id, max(consumer_version_order) as latest_consumer_version_order
      from all_pacts
      group by provider_id, consumer_id"
    )

    create_view(:latest_pacts,
      "select ap.*
      from all_pacts ap
      inner join latest_pact_consumer_version_orders lp
      on ap.consumer_id = lp.consumer_id
           and ap.provider_id = lp.provider_id
           and ap.consumer_version_order = latest_consumer_version_order"
    )
  end
end

Version data entries

171 entries across 171 versions & 1 rubygems

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