From 5ef6167aee483573090c4344d04947cff67c32c7 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Mon, 5 Aug 2024 15:25:35 +0000 Subject: [PATCH] Refs #37678 - Update evr migration to use DSL --- ...624121212_katello_recreate_evr_constructs.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/db/migrate/20240624121212_katello_recreate_evr_constructs.rb b/db/migrate/20240624121212_katello_recreate_evr_constructs.rb index 4cc31c0bb64..73eebc42f3e 100644 --- a/db/migrate/20240624121212_katello_recreate_evr_constructs.rb +++ b/db/migrate/20240624121212_katello_recreate_evr_constructs.rb @@ -1,14 +1,7 @@ class KatelloRecreateEvrConstructs < ActiveRecord::Migration[6.1] - def change - count = select_value <<~SQL - SELECT count(*) FROM pg_extension WHERE extname = 'evr'; - SQL - if count.to_i == 0 - return - else - execute <<~SQL - DROP EXTENSION evr CASCADE; - SQL + def up + if extension_enabled?('evr') + disable_extension('evr', force: :cascade) execute <<~SQL create type evr_array_item as ( @@ -156,4 +149,8 @@ def change create_trigger :evr_update_trigger_katello_installed_packages, on: :katello_installed_packages end end + + def down + fail ActiveRecord::IrreversibleMigration + end end