Sha256: ef897f51bd65756fa3d8f6fc44df44beb97fbcdb612da739dcf87b66e2e0be63

Contents?: true

Size: 1.13 KB

Versions: 34

Compression:

Stored size: 1.13 KB

Contents

Sequel.migration do
  change do
    create_view(:all_pacts,
      Sequel::Model.db[:pacts].select(:pacts__id, :c__id___consumer_id, :c__name___consumer_name,
      :cv__number___consumer_version_number, :cv__order___consumer_version_order,
      :p__id___provider_id, :p__name___provider_name,
      :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

34 entries across 34 versions & 1 rubygems

Version Path
pact_broker-2.0.0.beta.6 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.18.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-2.0.0.beta.5 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.18.0.beta.1 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.17.2 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.17.1 db/migrations/08_create_latest_pact_view.rb
pact_broker-2.0.0.beta.4 db/migrations/08_create_latest_pact_view.rb
pact_broker-2.0.0.beta.3 db/migrations/08_create_latest_pact_view.rb
pact_broker-2.0.0.beta.2 db/migrations/08_create_latest_pact_view.rb
pact_broker-2.0.0.beta.1 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.17.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.16.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.15.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.14.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.13.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.12.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.11.2 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.11.1 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.11.0 db/migrations/08_create_latest_pact_view.rb
pact_broker-1.10.0 db/migrations/08_create_latest_pact_view.rb