-
-
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: replace latest_verifications view with latest_verifications_for…
…_provider_versions
- Loading branch information
Showing
12 changed files
with
141 additions
and
41 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dir.glob(File.expand_path(File.join(__FILE__, "..", "ddl_statements", "*.rb"))).sort.each do | path | | ||
require path | ||
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,31 @@ | ||
HEAD_MATRIX_V1 = " | ||
select | ||
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order, | ||
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number, | ||
p.created_at as pact_created_at, | ||
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order, | ||
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at, | ||
lv.build_url as verification_build_url, | ||
null as consumer_version_tag_name | ||
from latest_pact_publications p | ||
left outer join latest_verifications lv | ||
on p.pact_version_id = lv.pact_version_id | ||
union all | ||
select | ||
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order, | ||
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number, | ||
p.created_at as pact_created_at, | ||
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order, | ||
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at, | ||
lv.build_url as verification_build_url, | ||
lt.tag_name as consumer_version_tag_name | ||
from latest_tagged_pact_consumer_version_orders lt | ||
inner join latest_pact_publications_by_consumer_versions p | ||
on lt.consumer_id = p.consumer_id | ||
and lt.provider_id = p.provider_id | ||
and lt.latest_consumer_version_order = p.consumer_version_order | ||
left outer join latest_verifications lv | ||
on p.pact_version_id = lv.pact_version_id | ||
" |
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,31 @@ | ||
HEAD_MATRIX_V2 = " | ||
select | ||
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order, | ||
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number, | ||
p.created_at as pact_created_at, | ||
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order, | ||
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at, | ||
lv.build_url as verification_build_url, | ||
null as consumer_version_tag_name | ||
from latest_pact_publications p | ||
left outer join latest_verifications_for_provider_versions lv | ||
on p.pact_version_id = lv.pact_version_id | ||
union all | ||
select | ||
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order, | ||
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number, | ||
p.created_at as pact_created_at, | ||
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order, | ||
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at, | ||
lv.build_url as verification_build_url, | ||
lt.tag_name as consumer_version_tag_name | ||
from latest_tagged_pact_consumer_version_orders lt | ||
inner join latest_pact_publications_by_consumer_versions p | ||
on lt.consumer_id = p.consumer_id | ||
and lt.provider_id = p.provider_id | ||
and lt.latest_consumer_version_order = p.consumer_version_order | ||
left outer join latest_verifications_for_provider_versions lv | ||
on p.pact_version_id = lv.pact_version_id | ||
" |
4 changes: 4 additions & 0 deletions
4
db/ddl_statements/latest_verification_ids_for_provider_versions_v001.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,4 @@ | ||
LATEST_VERIFICATION_IDS_FOR_PROVIDER_VERSIONS_V1 = | ||
"select pact_version_id, MAX(verification_id) latest_verification_id | ||
FROM latest_verification_id_for_pact_version_and_provider_version | ||
GROUP BY pact_version_id" |
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
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
20 changes: 20 additions & 0 deletions
20
db/migrations/20180728_truncate_materialized_matrix_tables.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,20 @@ | ||
Sequel.migration do | ||
up do | ||
from(:materialized_matrix).delete | ||
from(:materialized_head_matrix).delete | ||
|
||
# TODO | ||
# drop_view(:latest_matrix) | ||
# drop_view(:latest_verification_id_for_consumer_version_and_provider) | ||
# drop_view(:latest_matrix_for_consumer_version_and_provider_version) | ||
# drop_table(:materialized_matrix) | ||
# drop_table(:materialized_head_matrix) | ||
end | ||
|
||
down do | ||
from(:materialized_matrix).delete | ||
from(:materialized_matrix).insert(from(:matrix).select_all) | ||
from(:materialized_head_matrix).delete | ||
from(:materialized_head_matrix).insert(from(:head_matrix).select_all) | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
db/migrations/20180729_create_latest_verification_ids_for_provider_versions.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,8 @@ | ||
require_relative '../ddl_statements' | ||
|
||
Sequel.migration do | ||
change do | ||
create_view(:latest_verification_ids_for_provider_versions, | ||
LATEST_VERIFICATION_IDS_FOR_PROVIDER_VERSIONS_V1) | ||
end | ||
end |
29 changes: 29 additions & 0 deletions
29
db/migrations/20180730_create_latest_verifications_for_provider_versions.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,29 @@ | ||
Sequel.migration do | ||
change do | ||
# The most recent verification for each pact_version | ||
v = :verifications | ||
create_view(:latest_verifications_for_provider_versions, | ||
from(v) | ||
.select( | ||
Sequel[v][:id], | ||
Sequel[v][:number], | ||
Sequel[v][:success], | ||
Sequel[v][:build_url], | ||
Sequel[v][:pact_version_id], | ||
Sequel[v][:execution_date], | ||
Sequel[v][:created_at], | ||
Sequel[v][:provider_version_id], | ||
Sequel[:s][:number].as(:provider_version_number), | ||
Sequel[:s][:order].as(:provider_version_order)) | ||
.join(:latest_verification_ids_for_provider_versions, | ||
{ | ||
Sequel[v][:pact_version_id] => Sequel[:lv][:pact_version_id], | ||
Sequel[v][:id] => Sequel[:lv][:latest_verification_id] | ||
}, { table_alias: :lv }) | ||
.join(:versions, | ||
{ | ||
Sequel[v][:provider_version_id] => Sequel[:s][:id] | ||
}, { table_alias: :s }) | ||
) | ||
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,11 @@ | ||
Sequel.migration do | ||
up do | ||
create_or_replace_view(:head_matrix, HEAD_MATRIX_V2) | ||
#TODO | ||
#drop_view(:latest_verifications) | ||
end | ||
|
||
down do | ||
create_or_replace_view(:head_matrix, HEAD_MATRIX_V1) | ||
end | ||
end |
Binary file not shown.