Class: PGTrunk::Operations::Procedures::ChangeProcedure

Inherits:
Base show all
Defined in:
lib/pg_trunk/operations/procedures/change_procedure.rb

Instance Method Summary collapse

Methods included from PGTrunk::Operation::SQLHelpers

#quote

Methods included from PGTrunk::Operation::RubyHelpers

#dump, #to_a, #to_opts, #to_ruby

Methods included from PGTrunk::Operation::Inversion

#invert!, #irreversible!

Methods included from PGTrunk::Operation::Validations

#error_messages

Methods included from PGTrunk::Operation::Attributes

#attributes, #initialize

Instance Method Details

#invertObject



74
75
76
77
78
79
80
81
82
# File 'lib/pg_trunk/operations/procedures/change_procedure.rb', line 74

def invert
  irreversible!("if_exists: true") if if_exists
  undefined = inversion.select { |_, v| v.nil? }.keys.join(", ").presence
  raise IrreversibleMigration.new(self, nil, <<~MSG.squish) if undefined
    Undefined values to revert #{undefined}.
  MSG

  self.class.new(**inversion, name: name)
end

#to_sql(version) ⇒ Object



67
68
69
70
71
72
# File 'lib/pg_trunk/operations/procedures/change_procedure.rb', line 67

def to_sql(version)
  check_version!(version)

  # Use `CREATE OR REPLACE FUNCTION` to make changes
  create_procedure&.to_sql(version)
end