From 045f3f38dee8930167269d66a142f6b6d9d0925d Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 12 Sep 2019 10:40:56 +1000 Subject: [PATCH] fix: don't drop column from view in down step, because you can't remove a column from a view in posgres --- ...9_add_test_results_to_all_verifications.rb | 15 +---------- ...dd_test_results_to_latest_verifications.rb | 26 +------------------ ..._latest_verifications_for_pact_versions.rb | 26 +------------------ 3 files changed, 3 insertions(+), 64 deletions(-) diff --git a/db/migrations/20190909_add_test_results_to_all_verifications.rb b/db/migrations/20190909_add_test_results_to_all_verifications.rb index 92a5b4415..bd3248946 100644 --- a/db/migrations/20190909_add_test_results_to_all_verifications.rb +++ b/db/migrations/20190909_add_test_results_to_all_verifications.rb @@ -18,19 +18,6 @@ end down do - create_or_replace_view(:all_verifications, - from(:verifications).select( - Sequel[:verifications][:id], - Sequel[:verifications][:number], - :success, - :provider_version_id, - Sequel[:v][:number].as(:provider_version_number), - Sequel[:v][:order].as(:provider_version_order), - :build_url, - :pact_version_id, - :execution_date, - Sequel[:verifications][:created_at] - ).join(:versions, {id: :provider_version_id}, {:table_alias => :v}) - ) + # do nothing - you can't drop columns from a postgres view end end diff --git a/db/migrations/20190910_add_test_results_to_latest_verifications.rb b/db/migrations/20190910_add_test_results_to_latest_verifications.rb index 6ad780fe8..1da2fa669 100644 --- a/db/migrations/20190910_add_test_results_to_latest_verifications.rb +++ b/db/migrations/20190910_add_test_results_to_latest_verifications.rb @@ -32,30 +32,6 @@ end down do - v = :verifications - create_or_replace_view(:latest_verifications, - from(v) - .select( - Sequel[v][:id], - Sequel[v][:number], - Sequel[v][:success], - Sequel[:s][:number].as(:provider_version), - 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_numbers, - { - Sequel[v][:pact_version_id] => Sequel[:lv][:pact_version_id], - Sequel[v][:number] => Sequel[:lv][:latest_number] - }, { table_alias: :lv }) - .join(:versions, - { - Sequel[v][:provider_version_id] => Sequel[:s][:id] - }, { table_alias: :s }) - ) + # do nothing - you can't drop columns from a postgres view end end diff --git a/db/migrations/20190911_add_test_results_to_latest_verifications_for_pact_versions.rb b/db/migrations/20190911_add_test_results_to_latest_verifications_for_pact_versions.rb index d99f395db..46147885b 100644 --- a/db/migrations/20190911_add_test_results_to_latest_verifications_for_pact_versions.rb +++ b/db/migrations/20190911_add_test_results_to_latest_verifications_for_pact_versions.rb @@ -29,30 +29,6 @@ end down do - # The most recent verification for each pact_version - v = :verifications - create_or_replace_view(:latest_verifications_for_pact_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_pact_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 }) - ) + # do nothing - you can't drop columns from a postgres view end end