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.96.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.95.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.95.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.94.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.93.4 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.93.3 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.93.2 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.93.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.93.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.92.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.91.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.90.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.89.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.89.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.88.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.87.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.86.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.85.1 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.85.0 db/migrations/000014_add_timestamps_to_pact_views.rb
pact_broker-2.84.0 db/migrations/000014_add_timestamps_to_pact_views.rb