diff --git a/lib/pact_broker/domain/version.rb b/lib/pact_broker/domain/version.rb index f633b3492..5002f187b 100644 --- a/lib/pact_broker/domain/version.rb +++ b/lib/pact_broker/domain/version.rb @@ -12,6 +12,11 @@ class Version < Sequel::Model dataset_module do include PactBroker::Repositories::Helpers + + def delete + PactBroker::Domain::Tag.where(version: self).delete + super + end end def after_create diff --git a/lib/pact_broker/pacts/repository.rb b/lib/pact_broker/pacts/repository.rb index f12cdaf1d..00a7b6e97 100644 --- a/lib/pact_broker/pacts/repository.rb +++ b/lib/pact_broker/pacts/repository.rb @@ -105,7 +105,7 @@ def delete_all_pact_publications_between consumer_name, options def delete_all_pact_versions_between consumer_name, options consumer = pacticipant_repository.find_by_name(consumer_name) provider = pacticipant_repository.find_by_name(options.fetch(:and)) - PactVersion.where(consumer: consumer, provider: provider).destroy + PactVersion.where(consumer: consumer, provider: provider).delete end def find_latest_pact_versions_for_provider provider_name, tag = nil diff --git a/lib/pact_broker/verifications/repository.rb b/lib/pact_broker/verifications/repository.rb index 3a3dee358..40417d10e 100644 --- a/lib/pact_broker/verifications/repository.rb +++ b/lib/pact_broker/verifications/repository.rb @@ -123,7 +123,7 @@ def delete_by_provider_version_id version_id def delete_all_verifications_between(consumer_name, options) consumer = pacticipant_repository.find_by_name(consumer_name) provider = pacticipant_repository.find_by_name(options.fetch(:and)) - PactBroker::Domain::Verification.where(provider: provider, consumer: consumer).destroy + PactBroker::Domain::Verification.where(provider: provider, consumer: consumer).delete end def pact_version_id_for pact diff --git a/lib/pact_broker/versions/repository.rb b/lib/pact_broker/versions/repository.rb index 04a46f636..48771c960 100644 --- a/lib/pact_broker/versions/repository.rb +++ b/lib/pact_broker/versions/repository.rb @@ -89,7 +89,7 @@ def delete_orphan_versions consumer, provider PactBroker::Domain::Version .where(pacticipant_id: [consumer.id, provider.id]) .exclude(id: (version_ids_with_pact_publications + version_ids_with_verifications).uniq) - .destroy + .delete end end end