Sha256: d6e9897e91fdddaa7c8c1dd21e6243af190e065ba20c157dc51bc86b4a06a9c9

Contents?: true

Size: 1.31 KB

Versions: 171

Compression:

Stored size: 1.31 KB

Contents

Sequel.migration do
  change do
    create_or_replace_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], Sequel[:pacts][:created_at], Sequel[:pacts][:updated_at]).
      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_or_replace_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_or_replace_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.112.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.111.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.109.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.109.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.108.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.107.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.107.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.107.0.beta.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.106.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.105.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.104.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.103.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.102.2 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.102.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.102.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.101.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.100.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.99.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.98.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.97.0 db/migrations/000014_add_timestamps_to_pact_views.rb