pact_broker 2.24.0 → 2.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/CONTRIBUTING.md +2 -2
- data/DEVELOPER_DOCUMENTATION.md +31 -27
- data/DEVELOPER_SETUP.md +3 -2
- data/config/database.yml +10 -0
- data/db/ddl_statements.rb +3 -0
- data/db/ddl_statements/head_matrix_v001.rb +31 -0
- data/db/ddl_statements/head_matrix_v002.rb +31 -0
- data/db/ddl_statements/latest_verification_ids_for_pact_versions_v001.rb +4 -0
- data/db/migrations/000028_create_all_pact_publications.rb +4 -1
- data/db/migrations/20180311_optimise_head_matrix.rb +5 -34
- data/db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb +2 -0
- data/db/migrations/20180612_add_pacticipant_ids_to_verifications.rb +17 -0
- data/db/migrations/20180613_migrate_pacticipant_ids_for_verifications.rb +7 -0
- data/db/migrations/20180614_update_latest_verification_ids_for_consumer_and_provider.rb +27 -0
- data/db/migrations/20180615_add_consumer_id_to_pact_publications.rb +13 -0
- data/db/migrations/20180616_migrate_consumer_ids_for_pact_publications.rb +11 -0
- data/db/migrations/20180720_create_latest_pact_publication_ids.rb +25 -0
- data/db/migrations/20180721_migrate_latest_pact_publication_ids.rb +11 -0
- data/db/migrations/20180722_recreate_views.rb +43 -0
- data/db/migrations/20180723_create_latest_verification_ids.rb +23 -0
- data/db/migrations/20180724_migrate_latest_verification_ids.rb +18 -0
- data/db/migrations/20180726_recreate_views.rb +29 -0
- data/db/migrations/20180727_recreate_latest_verification_ids_for_consumer_version_tags.rb +34 -0
- data/db/migrations/20180728_truncate_materialized_matrix_tables.rb +20 -0
- data/db/migrations/20180729_create_latest_verification_ids_for_provider_versions.rb +8 -0
- data/db/migrations/20180730_create_latest_verifications_for_provider_versions.rb +33 -0
- data/db/migrations/20180731_update_head_matrix.rb +11 -0
- data/db/pact_broker_database.sqlite3 +0 -0
- data/lib/pact_broker/api.rb +3 -3
- data/lib/pact_broker/api/decorators/dashboard_text_decorator.rb +2 -2
- data/lib/pact_broker/api/pact_broker_urls.rb +1 -1
- data/lib/pact_broker/api/resources/base_resource.rb +0 -7
- data/lib/pact_broker/api/resources/index.rb +11 -9
- data/lib/pact_broker/api/resources/pact.rb +1 -3
- data/lib/pact_broker/api/resources/pacticipant.rb +1 -3
- data/lib/pact_broker/api/resources/tag.rb +1 -4
- data/lib/pact_broker/api/resources/verification.rb +2 -0
- data/lib/pact_broker/api/resources/version.rb +1 -3
- data/lib/pact_broker/app.rb +8 -0
- data/lib/pact_broker/certificates/certificate.rb +12 -0
- data/lib/pact_broker/config/setting.rb +12 -0
- data/lib/pact_broker/configuration.rb +2 -1
- data/lib/pact_broker/db.rb +6 -0
- data/lib/pact_broker/db/clean.rb +2 -7
- data/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications.rb +29 -0
- data/lib/pact_broker/db/data_migrations/set_pacticipant_ids_for_verifications.rb +35 -0
- data/lib/pact_broker/db/migrate_data.rb +14 -0
- data/lib/pact_broker/doc/views/wip-provider-pacts.markdown +3 -0
- data/lib/pact_broker/domain/label.rb +12 -0
- data/lib/pact_broker/domain/pacticipant.rb +32 -1
- data/lib/pact_broker/domain/tag.rb +14 -1
- data/lib/pact_broker/domain/verification.rb +29 -0
- data/lib/pact_broker/domain/version.rb +25 -1
- data/lib/pact_broker/feature_toggle.rb +23 -0
- data/lib/pact_broker/index/service.rb +1 -0
- data/lib/pact_broker/matrix/head_row.rb +25 -20
- data/lib/pact_broker/matrix/repository.rb +0 -18
- data/lib/pact_broker/matrix/row.rb +24 -27
- data/lib/pact_broker/matrix/service.rb +0 -8
- data/lib/pact_broker/pacts/all_pact_publications.rb +15 -0
- data/lib/pact_broker/pacts/latest_pact_publication_id_by_consumer_version.rb +34 -0
- data/lib/pact_broker/pacts/latest_pact_publications.rb +15 -0
- data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +15 -0
- data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +16 -0
- data/lib/pact_broker/pacts/pact_publication.rb +24 -0
- data/lib/pact_broker/pacts/pact_version.rb +20 -0
- data/lib/pact_broker/pacts/repository.rb +37 -11
- data/lib/pact_broker/pacts/service.rb +9 -2
- data/lib/pact_broker/repositories/helpers.rb +20 -0
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +8 -0
- data/lib/pact_broker/ui/view_models/index_item.rb +5 -1
- data/lib/pact_broker/ui/views/index/show.haml +1 -1
- data/lib/pact_broker/verifications/all_verifications.rb +13 -0
- data/lib/pact_broker/verifications/latest_verification_for_consumer_and_provider.rb +18 -0
- data/lib/pact_broker/verifications/latest_verification_for_consumer_version_tag.rb +19 -0
- data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +22 -0
- data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +36 -0
- data/lib/pact_broker/verifications/repository.rb +23 -5
- data/lib/pact_broker/verifications/sequence.rb +4 -0
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/execution.rb +16 -0
- data/lib/pact_broker/webhooks/latest_triggered_webhook.rb +14 -0
- data/lib/pact_broker/webhooks/triggered_webhook.rb +27 -0
- data/lib/pact_broker/webhooks/webhook.rb +26 -0
- data/lib/pact_broker/webhooks/webhook_event.rb +13 -0
- data/pact_broker.gemspec +1 -0
- data/script/recreate-docker-pg-db.sh +20 -0
- data/script/recreate-mysql-db.sh +1 -0
- data/spec/integration/webhooks/certificate_spec.rb +1 -1
- data/spec/lib/pact_broker/db/clean_spec.rb +1 -1
- data/spec/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications_spec.rb +40 -0
- data/spec/lib/pact_broker/feature_toggle_spec.rb +74 -0
- data/spec/lib/pact_broker/matrix/head_row_spec.rb +0 -44
- data/spec/lib/pact_broker/matrix/repository_spec.rb +0 -20
- data/spec/lib/pact_broker/matrix/row_spec.rb +0 -56
- data/spec/lib/pact_broker/pacts/repository_spec.rb +61 -9
- data/spec/lib/pact_broker/pacts/service_spec.rb +65 -17
- data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +3 -2
- data/spec/migrations/44_add_provider_version_to_verification_spec.rb +0 -1
- data/spec/service_consumers/provider_states_for_pact_ruby.rb +14 -0
- data/spec/support/test_data_builder.rb +0 -18
- data/tasks/database/annotate.rb +40 -0
- data/tasks/db.rake +12 -0
- metadata +50 -3
- data/lib/pact_broker/verifications/latest_verifications_by_consumer_version.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee46917fc8d40d1f2621e54b29820617690837c3
|
4
|
+
data.tar.gz: e8b2a5f1c826f21d9c8e974a4cee4d3a9fcca951
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 625e5ef7a725cd4f62a814f5387dcd2ad78692b1859c61f99cf577b1a325069b8d50b066c233eb5c48c0662a751409fe34a3d1e9b8672b71d29fde071700c359
|
7
|
+
data.tar.gz: 525863990061dcd5f96541e49ed063b277d3b9e33e39e617d21ca88a9dfcd33e701e9ea0d61333c08791f4e1e0375b80cb664768db8410b1f8725823ba0b7be8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
+
<a name="v2.25.0"></a>
|
2
|
+
### v2.25.0 (2018-08-09)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* make contract_content_changed tag aware ([8e7d0e47](/../../commit/8e7d0e47))
|
8
|
+
* move "latest id" upsert logic into own class ([360d236f](/../../commit/360d236f))
|
9
|
+
* replace latest_verifications view with latest_verifications_for_provider_versions ([ee4fef99](/../../commit/ee4fef99))
|
10
|
+
* sort tags in text/plain version of /dashboard ([0a821490](/../../commit/0a821490))
|
11
|
+
* optimise data migrations that set pacticipant ids ([9a148b80](/../../commit/9a148b80))
|
12
|
+
* add pact_version_id to latest_pact_publication_ids table ([627ce6db](/../../commit/627ce6db))
|
13
|
+
* optimise query for loading latest verification for the latest pacts for each tag on index page ([8bc58442](/../../commit/8bc58442))
|
14
|
+
* add consumer_id to pact_publications table ([d520e228](/../../commit/d520e228))
|
15
|
+
* add consumer id and provider id to verifications table to speed up queries ([d5698901](/../../commit/d5698901))
|
16
|
+
* run data migrations on startup to ensure data created by old nodes is migrated when performing a rolling update ([ec59ba5b](/../../commit/ec59ba5b))
|
17
|
+
* move migrations on feature branch to run last ([78d31c49](/../../commit/78d31c49))
|
18
|
+
* remove refresh of materialized_matrix and materialized_head_matrix ([262af756](/../../commit/262af756))
|
19
|
+
* keep track of the latest verification for a pact version for each provider version, rather than calculating it ([110495a9](/../../commit/110495a9))
|
20
|
+
* store latest pact publication ids for each consumer version ([d239bfdf](/../../commit/d239bfdf))
|
21
|
+
* keep track of latest pact revision in table rather than calculating it ([e9cd9e1b](/../../commit/e9cd9e1b))
|
22
|
+
* move pb:wip-provider-pacts to beta:wip-provider-pacts ([3008140a](/../../commit/3008140a))
|
23
|
+
* make feature toggles case insensitive and space aware ([f4a03c0c](/../../commit/f4a03c0c))
|
24
|
+
* add feature toggle via environment variable PACT_BROKER_FEATURES ([f0737b97](/../../commit/f0737b97))
|
25
|
+
* keep track of the latest verification for a pact version for each provider version, rather than calculating it ([b4f18770](/../../commit/b4f18770))
|
26
|
+
* store latest pact publication ids for each consumer version ([c8fa5545](/../../commit/c8fa5545))
|
27
|
+
* keep track of latest pact revision in table rather than calculating it ([1db5b7ba](/../../commit/1db5b7ba))
|
28
|
+
|
29
|
+
* **index**
|
30
|
+
* eager load latest verification for consumer and provider ([1bf61afc](/../../commit/1bf61afc))
|
31
|
+
|
32
|
+
|
33
|
+
#### Bug Fixes
|
34
|
+
|
35
|
+
* **index page**
|
36
|
+
* correct pact URL when showing index with tags ([a5bda98f](/../../commit/a5bda98f))
|
37
|
+
|
38
|
+
|
1
39
|
<a name="v2.24.0"></a>
|
2
40
|
### v2.24.0 (2018-07-08)
|
3
41
|
|
data/CONTRIBUTING.md
CHANGED
@@ -15,8 +15,8 @@ Please provide the following information with your issue to enable us to respond
|
|
15
15
|
* Write tests for any changes
|
16
16
|
* Follow existing code style and conventions
|
17
17
|
* Separate unrelated changes into multiple pull requests
|
18
|
-
* [Squash your commits]
|
19
|
-
* Use [semantic commit messages]
|
18
|
+
* [Squash your commits][squash] into one commit before submitting your PR.
|
19
|
+
* Use [semantic commit messages][semantic-commit-messages] so that your changes will show up correctly in the generated change log.
|
20
20
|
|
21
21
|
* For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change
|
22
22
|
|
data/DEVELOPER_DOCUMENTATION.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Developer Documentation
|
2
2
|
|
3
|
+
## File structure
|
4
|
+
|
5
|
+
* Application code - [lib](lib)
|
6
|
+
* List of API endpoints - [lib/pact_broker/api.rb](lib/pact_broker/api.rb)
|
7
|
+
* API - [lib/pact_broker/api](lib/pact_broker/api)
|
8
|
+
* HTTP Resources - [lib/pact_broker/api/resources](lib/pact_broker/api/resources) These handle the HTTP requests.
|
9
|
+
* Decorators - [lib/pact_broker/api/decorators](lib/pact_broker/api/decorators) These render the response bodies.
|
10
|
+
* Contracts - [lib/pact_broker/api/contracts](lib/pact_broker/api/contracts) These validate incoming API requests.
|
11
|
+
* Domain - Domain classes were intially created in [lib/pact_broker/domain](lib/pact_broker/domain) but are now put in their own modules. The ones left here just haven't been migrated yet.
|
12
|
+
* Database migrations - [db/migrations](db/migrations)
|
13
|
+
|
14
|
+
* Tests - `spec`
|
15
|
+
* Isolated tests (mostly) - `spec/lib`
|
16
|
+
* Contract tests - `spec/service_consumers`
|
17
|
+
* High level API functional tests - `spec/features`
|
18
|
+
* Migration tests - `spec/migrations`
|
19
|
+
|
3
20
|
## Domain and database design
|
4
21
|
|
5
22
|
### Domain
|
@@ -54,38 +71,25 @@ Domain classes are found in `lib/pact_broker/domain`. Many of these classes are
|
|
54
71
|
|
55
72
|
* `latest_tagged_pact_publications` - This view has the same columns as `all_pact_publications`, plus a `tag_name` column. It is used to return the pact for the latest tagged version of a consumer.
|
56
73
|
|
57
|
-
* `
|
74
|
+
* `latest_verifications_for_pact_versions` - The most recent verification for each pact version.
|
58
75
|
|
59
76
|
* `matrix` - The matrix of every pact publication and verification. Includes every pact revision (eg. publishing to the same consumer version twice, or using PATCH) and every verification (including 'overwritten' ones. eg. when the same provider build runs twice.)
|
60
77
|
|
61
|
-
* `latest_matrix_for_consumer_version_and_provider_version` - This view is a subset of, and has the same columns as, the `matrix`. It removes 'overwritten' pacts and verifications from the matrix (ie. only show latest pact revision for each consumer version and latest verification for each provider version)
|
62
|
-
|
63
|
-
### Materialized Views
|
64
|
-
|
65
|
-
We can't use proper materialized views because we have to support MySQL :|
|
66
|
-
|
67
|
-
So as a hacky solution, there are two tables which act as materialized views to speed up the performance of the matrix and index queries. These tables are updated after any resource is published with a `consumer_name`, `provider_name` or `pacticipant_name` in the URL (see lib/pact_broker/api/resources/base_resource.rb#finish_request).
|
68
|
-
|
69
|
-
* `materialized_matrix` table - is populated from the `matrix` view.
|
70
|
-
|
71
|
-
* `materialized_head_matrix` table - is populated from `head_matrix` view, and is based on `materialized_matrix`.
|
72
|
-
|
73
78
|
### Dependencies
|
74
79
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
-> latest_pact_publication_revision_numbers view
|
80
|
+
```
|
81
|
+
= head_matrix view
|
82
|
+
-> latest_pact_publications view
|
83
|
+
-> latest_pact_publications_by_consumer_versions view
|
84
|
+
-> latest_pact_publication_ids_by_consumer_versions
|
85
|
+
-> all_pact_publications
|
86
|
+
-> versions, pacticipants, pact_publications, pact_versions
|
87
|
+
-> latest_verifications_for_pact_versions
|
88
|
+
-> latest_verification_ids_for_pact_versions
|
89
|
+
-> versions
|
90
|
+
-> latest_tagged_pact_consumer_version_orders
|
91
|
+
-> latest_pact_publications_by_consumer_versions
|
92
|
+
```
|
89
93
|
|
90
94
|
### Useful to know stuff
|
91
95
|
|
data/DEVELOPER_SETUP.md
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
* You will need to install Ruby 2.4, and preferably a ruby version manager. I recommend using [chruby][chruby] and [ruby-install][ruby-install].
|
4
4
|
* Install bundler (the Ruby gem dependency manager) `gem install bundler`
|
5
|
-
* Check out the pact_broker repository.
|
6
|
-
* Run `bundle
|
5
|
+
* Check out the pact_broker repository and cd into it.
|
6
|
+
* Run `bundle install`. If you have not got mysql or postgres installed locally, comment out the `mysql2` and `pg` development dependency lines in `pact_broker.gemspec`, as these are only really required on Travis.
|
7
|
+
* Run `bundle exec rake pact_broker:dev:setup`. This will create an example application that you can run locally, that uses the local source code.
|
7
8
|
* To run the example:
|
8
9
|
|
9
10
|
cd dev
|
data/config/database.yml
CHANGED
@@ -11,6 +11,11 @@ test:
|
|
11
11
|
postgres:
|
12
12
|
<<: *default
|
13
13
|
adapter: postgres
|
14
|
+
docker_postgres:
|
15
|
+
<<: *default
|
16
|
+
adapter: postgres
|
17
|
+
host: "127.0.0.1"
|
18
|
+
port: "5433"
|
14
19
|
mysql:
|
15
20
|
<<: *default
|
16
21
|
adapter: mysql2
|
@@ -22,6 +27,11 @@ development:
|
|
22
27
|
postgres:
|
23
28
|
<<: *default
|
24
29
|
adapter: postgres
|
30
|
+
docker_postgres:
|
31
|
+
<<: *default
|
32
|
+
adapter: postgres
|
33
|
+
host: "127.0.0.1"
|
34
|
+
port: "5433"
|
25
35
|
mysql:
|
26
36
|
<<: *default
|
27
37
|
adapter: mysql2
|
@@ -0,0 +1,31 @@
|
|
1
|
+
HEAD_MATRIX_V1 = "
|
2
|
+
select
|
3
|
+
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order,
|
4
|
+
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number,
|
5
|
+
p.created_at as pact_created_at,
|
6
|
+
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order,
|
7
|
+
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at,
|
8
|
+
lv.build_url as verification_build_url,
|
9
|
+
null as consumer_version_tag_name
|
10
|
+
from latest_pact_publications p
|
11
|
+
left outer join latest_verifications lv
|
12
|
+
on p.pact_version_id = lv.pact_version_id
|
13
|
+
|
14
|
+
union all
|
15
|
+
|
16
|
+
select
|
17
|
+
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order,
|
18
|
+
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number,
|
19
|
+
p.created_at as pact_created_at,
|
20
|
+
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order,
|
21
|
+
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at,
|
22
|
+
lv.build_url as verification_build_url,
|
23
|
+
lt.tag_name as consumer_version_tag_name
|
24
|
+
from latest_tagged_pact_consumer_version_orders lt
|
25
|
+
inner join latest_pact_publications_by_consumer_versions p
|
26
|
+
on lt.consumer_id = p.consumer_id
|
27
|
+
and lt.provider_id = p.provider_id
|
28
|
+
and lt.latest_consumer_version_order = p.consumer_version_order
|
29
|
+
left outer join latest_verifications lv
|
30
|
+
on p.pact_version_id = lv.pact_version_id
|
31
|
+
"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
HEAD_MATRIX_V2 = "
|
2
|
+
select
|
3
|
+
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order,
|
4
|
+
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number,
|
5
|
+
p.created_at as pact_created_at,
|
6
|
+
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order,
|
7
|
+
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at,
|
8
|
+
lv.build_url as verification_build_url,
|
9
|
+
null as consumer_version_tag_name
|
10
|
+
from latest_pact_publications p
|
11
|
+
left outer join latest_verifications_for_pact_versions lv
|
12
|
+
on p.pact_version_id = lv.pact_version_id
|
13
|
+
|
14
|
+
union all
|
15
|
+
|
16
|
+
select
|
17
|
+
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order,
|
18
|
+
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number,
|
19
|
+
p.created_at as pact_created_at,
|
20
|
+
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order,
|
21
|
+
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at,
|
22
|
+
lv.build_url as verification_build_url,
|
23
|
+
lt.tag_name as consumer_version_tag_name
|
24
|
+
from latest_tagged_pact_consumer_version_orders lt
|
25
|
+
inner join latest_pact_publications_by_consumer_versions p
|
26
|
+
on lt.consumer_id = p.consumer_id
|
27
|
+
and lt.provider_id = p.provider_id
|
28
|
+
and lt.latest_consumer_version_order = p.consumer_version_order
|
29
|
+
left outer join latest_verifications_for_pact_versions lv
|
30
|
+
on p.pact_version_id = lv.pact_version_id
|
31
|
+
"
|
@@ -21,7 +21,8 @@ Sequel.migration do
|
|
21
21
|
group by provider_id, consumer_id, consumer_version_order"
|
22
22
|
)
|
23
23
|
|
24
|
-
# Latest pact_publication
|
24
|
+
# Latest pact_publication (revision) for each provider/consumer version
|
25
|
+
# updated in 20180519_recreate_views.rb
|
25
26
|
create_view(:latest_pact_publications_by_consumer_versions,
|
26
27
|
"select app.*
|
27
28
|
from all_pact_publications app
|
@@ -33,6 +34,8 @@ Sequel.migration do
|
|
33
34
|
)
|
34
35
|
|
35
36
|
|
37
|
+
# updated in 20180519_recreate_views.rb
|
38
|
+
# This view tells us the latest consumer version with a pact for a consumer/provider pair
|
36
39
|
create_or_replace_view(:latest_pact_consumer_version_orders,
|
37
40
|
"select provider_id, consumer_id, max(consumer_version_order) as latest_consumer_version_order
|
38
41
|
from all_pact_publications
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'migration_helper'
|
2
|
+
require_relative '../ddl_statements'
|
2
3
|
|
3
4
|
Sequel.migration do
|
4
5
|
up do
|
@@ -16,7 +17,9 @@ Sequel.migration do
|
|
16
17
|
)
|
17
18
|
|
18
19
|
# Add provider_version_order to original definition
|
19
|
-
# The most recent verification for each
|
20
|
+
# The most recent verification for each pact_version
|
21
|
+
# provider_version column is DEPRECATED, use provider_version_number
|
22
|
+
# Think this can be replaced by latest_verification_id_for_pact_version_and_provider_version?
|
20
23
|
v = :verifications
|
21
24
|
create_or_replace_view(:latest_verifications,
|
22
25
|
from(v)
|
@@ -44,38 +47,6 @@ Sequel.migration do
|
|
44
47
|
)
|
45
48
|
|
46
49
|
|
47
|
-
create_or_replace_view(:head_matrix,
|
48
|
-
"
|
49
|
-
select
|
50
|
-
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order,
|
51
|
-
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number,
|
52
|
-
p.created_at as pact_created_at,
|
53
|
-
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order,
|
54
|
-
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at,
|
55
|
-
lv.build_url as verification_build_url,
|
56
|
-
null as consumer_version_tag_name
|
57
|
-
from latest_pact_publications p
|
58
|
-
left outer join latest_verifications lv
|
59
|
-
on p.pact_version_id = lv.pact_version_id
|
60
|
-
|
61
|
-
union all
|
62
|
-
|
63
|
-
select
|
64
|
-
p.consumer_id, p.consumer_name, p.consumer_version_id, p.consumer_version_number, p.consumer_version_order,
|
65
|
-
p.id as pact_publication_id, p.pact_version_id, p.pact_version_sha, p.revision_number as pact_revision_number,
|
66
|
-
p.created_at as pact_created_at,
|
67
|
-
p.provider_id, p.provider_name, lv.provider_version_id, lv.provider_version_number, lv.provider_version_order,
|
68
|
-
lv.id as verification_id, lv.success, lv.number as verification_number, lv.execution_date as verification_executed_at,
|
69
|
-
lv.build_url as verification_build_url,
|
70
|
-
lt.tag_name as consumer_version_tag_name
|
71
|
-
from latest_tagged_pact_consumer_version_orders lt
|
72
|
-
inner join latest_pact_publications_by_consumer_versions p
|
73
|
-
on lt.consumer_id = p.consumer_id
|
74
|
-
and lt.provider_id = p.provider_id
|
75
|
-
and lt.latest_consumer_version_order = p.consumer_version_order
|
76
|
-
left outer join latest_verifications lv
|
77
|
-
on p.pact_version_id = lv.pact_version_id
|
78
|
-
"
|
79
|
-
)
|
50
|
+
create_or_replace_view(:head_matrix, HEAD_MATRIX_V1)
|
80
51
|
end
|
81
52
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
Sequel.migration do
|
2
2
|
up do
|
3
3
|
# The latest verification id for each consumer version tag
|
4
|
+
# This is not the latest verification for the latest pact with a given tag,
|
5
|
+
# this is the latest verification for any pact with the tag
|
4
6
|
create_view(:latest_verification_ids_for_consumer_version_tags,
|
5
7
|
"select
|
6
8
|
pv.pacticipant_id as provider_id,
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
alter_table(:verifications) do
|
4
|
+
add_foreign_key(:consumer_id, :pacticipants)
|
5
|
+
add_foreign_key(:provider_id, :pacticipants)
|
6
|
+
add_index(:consumer_id, name: "verifications_consumer_id_index")
|
7
|
+
add_index(:provider_id, name: "verifications_provider_id_index")
|
8
|
+
add_index([:provider_id, :consumer_id], name: "verifications_provider_id_consumer_id_index")
|
9
|
+
end
|
10
|
+
|
11
|
+
# TODO
|
12
|
+
# alter_table(:verifications) do
|
13
|
+
# set_column_not_null(:consumer_id)
|
14
|
+
# set_column_not_null(:provider_id)
|
15
|
+
# end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# The latest verification id for each consumer version tag
|
4
|
+
create_or_replace_view(:latest_verification_ids_for_consumer_and_provider,
|
5
|
+
"select
|
6
|
+
provider_id,
|
7
|
+
consumer_id,
|
8
|
+
max(id) as latest_verification_id
|
9
|
+
from verifications v
|
10
|
+
group by provider_id, consumer_id")
|
11
|
+
end
|
12
|
+
|
13
|
+
down do
|
14
|
+
# The latest verification id for each consumer version tag
|
15
|
+
create_or_replace_view(:latest_verification_ids_for_consumer_and_provider,
|
16
|
+
"select
|
17
|
+
pv.pacticipant_id as provider_id,
|
18
|
+
lpp.consumer_id,
|
19
|
+
max(v.id) as latest_verification_id
|
20
|
+
from verifications v
|
21
|
+
join latest_pact_publications_by_consumer_versions lpp
|
22
|
+
on v.pact_version_id = lpp.pact_version_id
|
23
|
+
join versions pv
|
24
|
+
on v.provider_version_id = pv.id
|
25
|
+
group by pv.pacticipant_id, lpp.consumer_id")
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
alter_table(:pact_publications) do
|
4
|
+
add_foreign_key(:consumer_id, :pacticipants)
|
5
|
+
add_index(:consumer_id, name: "pact_publications_consumer_id_index")
|
6
|
+
end
|
7
|
+
|
8
|
+
# TODO
|
9
|
+
# alter_table(:pact_publications) do
|
10
|
+
# set_column_not_null(:consumer_id)
|
11
|
+
# end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications'
|
2
|
+
|
3
|
+
Sequel.migration do
|
4
|
+
up do
|
5
|
+
PactBroker::DB::DataMigrations::SetConsumerIdsForPactPublications.call(self)
|
6
|
+
end
|
7
|
+
|
8
|
+
down do
|
9
|
+
from(:pact_publications).update(consumer_id: nil)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
# Latest pact_publication (revision) for each provider/consumer version.
|
4
|
+
# Keeping track of this in a table rather than having to calculate the
|
5
|
+
# latest revision speeds things up.
|
6
|
+
# We don't have to worry about updating it if a revision is deleted, because
|
7
|
+
# you can't delete a single pact revision through the API - all the revisions
|
8
|
+
# for a pact are deleted together when you delete the pact resource for that
|
9
|
+
# consumer version, and when that happens, this row will cascade delete.
|
10
|
+
|
11
|
+
create_table(:latest_pact_publication_ids_for_consumer_versions, charset: 'utf8') do
|
12
|
+
foreign_key :consumer_id, :pacticipants, null: false, on_delete: :cascade # redundant, but speeds up queries by removing need for extra join
|
13
|
+
foreign_key :consumer_version_id, :versions, null: false, on_delete: :cascade
|
14
|
+
foreign_key :provider_id, :pacticipants, null: false, on_delete: :cascade
|
15
|
+
foreign_key :pact_publication_id, :pact_publications, null: false, on_delete: :cascade, unique: true
|
16
|
+
foreign_key :pact_version_id, :pact_versions, null: false, on_delete: :cascade
|
17
|
+
index [:provider_id, :consumer_version_id], unique: true, name: "unq_latest_ppid_prov_conver"
|
18
|
+
index [:provider_id, :consumer_id], name: "lpp_provider_id_consumer_id_index"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
down do
|
23
|
+
drop_table(:latest_pact_publication_ids_for_consumer_versions)
|
24
|
+
end
|
25
|
+
end
|