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.52.1 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.52.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.51.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.50.1 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.50.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.49.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.48.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.47.1 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.47.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.46.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.45.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.44.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.43.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.42.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.41.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.40.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.39.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.38.1 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.38.0 db/migrations/20180828_create_latest_versions.rb
pact_broker-2.37.0 db/migrations/20180828_create_latest_versions.rb