Class: PGTrunk::Operations::Triggers::ChangeTrigger
- Inherits:
-
Base
show all
- Defined in:
- lib/pg_trunk/operations/triggers/change_trigger.rb
Instance Method Summary
collapse
Methods inherited from Base
#<=>
#quote
#dump, #to_a, #to_opts, #to_ruby
#invert!, #irreversible!
#error_messages
#attributes, #initialize
Instance Method Details
#invert ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/pg_trunk/operations/triggers/change_trigger.rb', line 44
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, table: table, name: name)
end
|
#to_sql(server_version) ⇒ Object
38
39
40
41
42
|
# File 'lib/pg_trunk/operations/triggers/change_trigger.rb', line 38
def to_sql(server_version)
return create_trigger&.to_sql(server_version) if server_version >= "14"
raise "The operation is supported by PostgreSQL server v14+"
end
|