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 a815009
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions db/migrate/20240624121212_katello_recreate_evr_constructs.rb
Original file line number Diff line number Diff line change
@@ -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')

execute <<~SQL
create type evr_array_item as (
Expand Down Expand Up @@ -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

0 comments on commit a815009

Please sign in to comment.