Sha256: 43b314c0bfe70972eb022e4aefc2b166b86879683e9a1ac6d8273c44cee21517

Contents?: true

Size: 1.06 KB

Versions: 45

Compression:

Stored size: 1.06 KB

Contents

require_relative "../ddl_statements/latest_triggered_webhooks"

Sequel.migration do
  up do
    create_or_replace_view(:latest_triggered_webhook_creation_dates, latest_triggered_webhook_creation_dates_v2)
    create_or_replace_view(:latest_triggered_webhook_ids, latest_triggered_webhook_ids_v2)
    create_or_replace_view(:latest_triggered_webhooks, latest_triggered_webhooks_v2)
  end

  down do
    create_or_replace_view(:latest_triggered_webhook_ids,
      "select webhook_uuid, consumer_id, provider_id, max(created_at) as latest_triggered_webhook_created_at
      from triggered_webhooks
      group by webhook_uuid, consumer_id, provider_id"
    )

    create_or_replace_view(:latest_triggered_webhooks,
      "select tw.*
      from triggered_webhooks tw
      inner join latest_triggered_webhook_ids ltwi
      on tw.consumer_id = ltwi.consumer_id
      and tw.provider_id = ltwi.provider_id
      and tw.webhook_uuid = ltwi.webhook_uuid
      and tw.created_at = ltwi.latest_triggered_webhook_created_at"
    )

    drop_view(:latest_triggered_webhook_creation_dates)
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
pact_broker-2.97.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.96.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.95.1 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.95.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.94.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.93.4 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.93.3 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.93.2 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.93.1 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.93.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.92.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.91.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.90.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.89.1 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.89.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.88.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.87.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.86.0 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.85.1 db/migrations/20180119_update_latest_triggered_webhooks.rb
pact_broker-2.85.0 db/migrations/20180119_update_latest_triggered_webhooks.rb