forked from pact-foundation/pact_broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20180723_create_latest_verification_ids.rb
23 lines (22 loc) · 1.72 KB
/
20180723_create_latest_verification_ids.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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.
# There is no way to delete an individual verification result yet, but when there
# is, we'll need to re-calculate the latest.
create_table(:latest_verification_id_for_pact_version_and_provider_version, charset: 'utf8') do
foreign_key :consumer_id, :pacticipants, null: false, on_delete: :cascade, foreign_key_constraint_name: 'latest_v_id_for_pv_and_pv_consumer_id_fk' # not required, but useful to avoid extra joins
foreign_key :pact_version_id, :pact_versions, null: false, on_delete: :cascade, foreign_key_constraint_name: 'latest_v_id_for_pv_and_pv_pact_version_id_fk'
foreign_key :provider_id, :pacticipants, null: false, on_delete: :cascade, foreign_key_constraint_name: 'latest_v_id_for_pv_and_pv_provider_id_fk' # not required, but useful to avoid extra joins
foreign_key :provider_version_id, :versions, null: false, on_delete: :cascade, foreign_key_constraint_name: 'latest_v_id_for_pv_and_pv_provider_version_id_fk'
foreign_key :verification_id, :verifications, null: false, on_delete: :cascade, foreign_key_constraint_name: 'latest_v_id_for_pv_and_pv_verification_id_fk'
index [:verification_id], unique: true, name: "latest_v_id_for_pv_and_pv_v_id_unq"
index [:pact_version_id, :provider_version_id], unique: true, name: "latest_v_id_for_pv_and_pv_pv_id_pv_id_unq"
index [:pact_version_id, :verification_id], name: "latest_v_id_for_pv_and_pv_pv_id_v_id"
end
end
down do
drop_table(:latest_verification_id_for_pact_version_and_provider_version)
end
end