Skip to content

Commit

Permalink
feat: add indexes to webhook_executions and triggered_webhooks tables
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jan 15, 2021
1 parent de41b23 commit b05e7db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions db/migrations/20210115_add_webhook_foreign_key_indexes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative 'migration_helper'

include PactBroker::MigrationHelper

Sequel.migration do
change do
alter_table(:webhook_executions) do
add_index([:triggered_webhook_id], name: "webhook_executions_triggered_webhook_id_index")
end

alter_table(:triggered_webhooks) do
add_index([:webhook_id], name: "triggered_webhooks_webhook_id_index")
add_index([:consumer_id], name: "triggered_webhooks_consumer_id_index")
add_index([:provider_id], name: "triggered_webhooks_provider_id_index")
add_index([:pact_publication_id], name: "triggered_webhooks_pact_publication_id_index")
add_index([:verification_id], name: "triggered_webhooks_verification_id_index")
end
end
end
8 changes: 8 additions & 0 deletions db/migrations/migration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def adapter
Sequel::Model.db.adapter_scheme.to_s
end

def with_type_hash_if_postgres(options)
if postgres?
options.merge(type: "hash")
else
options
end
end

def sqlite_safe string
if adapter == 'sqlite'
string.gsub(/(?:\b|")order(?:"|\b)/, '`order`')
Expand Down

0 comments on commit b05e7db

Please sign in to comment.