Sha256: d5171e69d1a093a2df4a16b2ca5d555cbc23dd471f1eda2588991a4f7af20df0

Contents?: true

Size: 770 Bytes

Versions: 36

Compression:

Stored size: 770 Bytes

Contents

Sequel.migration do
  up do
    latest_version_orders = from(:versions)
                              .select_group(:pacticipant_id)
                              .select_append{ max(order).as(latest_version_order) }

    create_or_replace_view(:latest_version_orders, latest_version_orders)

    join = {
      Sequel[:versions][:pacticipant_id] => Sequel[:latest_version_orders][:pacticipant_id],
      Sequel[:versions][:order] => Sequel[:latest_version_orders][:latest_version_order]
    }

    latest_versions = from(:versions)
      .select(Sequel[:versions].*)
      .join(:latest_version_orders, join)

    create_or_replace_view(:latest_versions, latest_versions)
  end

  down do
    drop_view(:latest_version_orders)
    drop_view(:latest_versions)
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
pact_broker-2.36.1 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.36.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.35.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.34.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.33.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.32.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.31.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.30.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.29.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.27.6 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.27.5 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.27.4 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.27.3 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.27.2 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.27.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.26.1 db/migrations/20180828_create_latest_versions.rb