Skip to content

Commit

Permalink
Refs #37678 - Update evr migration to use DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 committed Aug 5, 2024
1 parent 98555b6 commit 97447fd
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions db/migrate/20240624121212_katello_recreate_evr_constructs.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
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
def up
if !extension_enabled?('evr')
return
else
execute <<~SQL
DROP EXTENSION evr CASCADE;
SQL
disable_extension('evr')

execute <<~SQL
create type evr_array_item as (
Expand Down Expand Up @@ -154,6 +149,10 @@ def change
create_trigger :evr_update_trigger_katello_rpms, on: :katello_rpms
create_trigger :evr_insert_trigger_katello_installed_packages, on: :katello_installed_packages
create_trigger :evr_update_trigger_katello_installed_packages, on: :katello_installed_packages
end
end
end

def down
fail ActiveRecord::IrreversibleMigration
end
end

0 comments on commit 97447fd

Please sign in to comment.