-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move "latest id" upsert logic into own class
- Loading branch information
Showing
5 changed files
with
80 additions
and
24 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
lib/pact_broker/pacts/latest_pact_publication_id_by_consumer_version.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'pact_broker/pacts/all_pact_publications' | ||
require 'pact_broker/repositories/helpers' | ||
|
||
module PactBroker | ||
module Pacts | ||
class LatestPactPublicationIdForConsumerVersion < Sequel::Model(:latest_pact_publication_ids_for_consumer_versions) | ||
|
||
dataset_module do | ||
include PactBroker::Repositories::Helpers | ||
end | ||
|
||
def upsert | ||
self.class.upsert(to_hash, [:provider_id, :consumer_version_id]) | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Table: latest_pact_publications_by_consumer_versions | ||
# Columns: | ||
# id | integer | | ||
# consumer_id | integer | | ||
# consumer_name | text | | ||
# consumer_version_id | integer | | ||
# consumer_version_number | text | | ||
# consumer_version_order | integer | | ||
# provider_id | integer | | ||
# provider_name | text | | ||
# revision_number | integer | | ||
# pact_version_id | integer | | ||
# pact_version_sha | text | | ||
# created_at | timestamp without time zone | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'pact_broker/domain/verification' | ||
|
||
module PactBroker | ||
module Verifications | ||
class LatestVerificationIdForPactVersionAndProviderVersion < Sequel::Model(:latest_verification_id_for_pact_version_and_provider_version) | ||
dataset_module do | ||
include PactBroker::Repositories::Helpers | ||
end | ||
|
||
def upsert | ||
self.class.upsert(to_hash, [:pact_version_id, :provider_version_id]) | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Table: latest_verification_id_for_pact_version_and_provider_version | ||
# Columns: | ||
# consumer_id | integer | NOT NULL | ||
# pact_version_id | integer | NOT NULL | ||
# provider_id | integer | NOT NULL | ||
# provider_version_id | integer | NOT NULL | ||
# verification_id | integer | NOT NULL | ||
# Indexes: | ||
# latest_v_id_for_pv_and_pv_pv_id_pv_id_unq | UNIQUE btree (pact_version_id, provider_version_id) | ||
# latest_v_id_for_pv_and_pv_v_id_unq | UNIQUE btree (verification_id) | ||
# latest_v_id_for_pv_and_pv_pv_id_v_id | btree (pact_version_id, verification_id) | ||
# Foreign key constraints: | ||
# latest_v_id_for_pv_and_pv_consumer_id_fk | (consumer_id) REFERENCES pacticipants(id) ON DELETE CASCADE | ||
# latest_v_id_for_pv_and_pv_pact_version_id_fk | (pact_version_id) REFERENCES pact_versions(id) ON DELETE CASCADE | ||
# latest_v_id_for_pv_and_pv_provider_id_fk | (provider_id) REFERENCES pacticipants(id) ON DELETE CASCADE | ||
# latest_v_id_for_pv_and_pv_provider_version_id_fk | (provider_version_id) REFERENCES versions(id) ON DELETE CASCADE | ||
# latest_v_id_for_pv_and_pv_verification_id_fk | (verification_id) REFERENCES verifications(id) ON DELETE CASCADE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters