diff --git a/db/migrations/20210115_add_webhook_foreign_key_indexes.rb b/db/migrations/20210115_add_webhook_foreign_key_indexes.rb new file mode 100644 index 000000000..f2e7a678e --- /dev/null +++ b/db/migrations/20210115_add_webhook_foreign_key_indexes.rb @@ -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 diff --git a/db/migrations/migration_helper.rb b/db/migrations/migration_helper.rb index 3a49c1ee3..84f35a869 100644 --- a/db/migrations/migration_helper.rb +++ b/db/migrations/migration_helper.rb @@ -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`')