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.2.0 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.1.1 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.1.0 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.5 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.4 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.3 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.2 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.1 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.0 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.0.beta.8 db/migrations/14_add_timestamps_to_pact_views.rb
pact_broker-2.0.0.beta.7 db/migrations/14_add_timestamps_to_pact_views.rb