-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: keep track of the latest verification for a pact version for ea…
…ch provider version, rather than calculating it
- Loading branch information
Showing
6 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Sequel.migration do | ||
up do | ||
# Latest verification_id for each pact version/provider version. | ||
# Keeping track of this in a table rather than having to calculate the | ||
# latest revision speeds queries up. | ||
create_table(:latest_verification_id_for_pact_version_and_provider_version, charset: 'utf8') do | ||
foreign_key :pact_version_id, :pact_versions, nil: false, on_delete: :cascade | ||
foreign_key :provider_version_id, :versions, nil: false, on_delete: :cascade | ||
foreign_key :provider_id, :pacticipants, nil: false, on_delete: :cascade | ||
foreign_key :verification_id, :verifications, nil: false, on_delete: :cascade, unique: true | ||
index [:pact_version_id, :provider_version_id], unique: true, name: "unq_latest_verifid_pvid_provid" | ||
end | ||
end | ||
|
||
down do | ||
drop_table(:latest_verification_id_for_pact_version_and_provider_version) | ||
end | ||
end |
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,18 @@ | ||
Sequel.migration do | ||
up do | ||
# Not sure if we need the provider_id, but it might come in handy | ||
rows = from(:verifications).select_group( | ||
Sequel[:verifications][:pact_version_id], | ||
Sequel[:verifications][:provider_version_id], | ||
Sequel[:versions][:pacticipant_id].as(:provider_id)) | ||
.select_append{ max(verifications[id]).as(verification_id) } | ||
.join(:versions, { Sequel[:verifications][:provider_version_id] => Sequel[:versions][:id] }) | ||
|
||
# The danger with this migration is that a verification created by an old node will be lost | ||
from(:latest_verification_id_for_pact_version_and_provider_version).insert(rows) | ||
end | ||
|
||
down do | ||
|
||
end | ||
end |
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,30 @@ | ||
Sequel.migration do | ||
up do | ||
# joining with latest_pact_publication_revision_numbers gets rid of the overwritten | ||
# pact revisions, and the max(verification_id) gets rid of the overwritten | ||
# verifications | ||
create_or_replace_view(:latest_verification_id_for_consumer_version_and_provider_version, | ||
"select pp.consumer_version_id, lv.provider_version_id, lv.verification_id as latest_verification_id | ||
from latest_pact_publication_ids_by_consumer_versions lpp | ||
inner join pact_publications pp | ||
on pp.id = lpp.pact_publication_id | ||
left outer join latest_verification_id_for_pact_version_and_provider_version lv | ||
on lv.pact_version_id = pp.pact_version_id" | ||
) | ||
|
||
end | ||
|
||
down do | ||
create_or_replace_view(:latest_verification_id_for_consumer_version_and_provider_version, | ||
"select consumer_version_id, provider_version_id, max(verification_id) as latest_verification_id | ||
from matrix | ||
inner join latest_pact_publication_revision_numbers lr | ||
on matrix.consumer_id = lr.consumer_id | ||
and matrix.provider_id = lr.provider_id | ||
and matrix.consumer_version_order = lr.consumer_version_order | ||
and matrix.pact_revision_number = lr.latest_revision_number | ||
group by consumer_version_id, provider_version_id" | ||
) | ||
|
||
end | ||
end |
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