Class: PGTrunk::Operations::ForeignKeys::DropForeignKey
- Inherits:
-
Base
show all
- Defined in:
- lib/pg_trunk/operations/foreign_keys/drop_foreign_key.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
80
81
82
83
|
# File 'lib/pg_trunk/operations/foreign_keys/drop_foreign_key.rb', line 80
def invert
irreversible!("if_exists: true") if if_exists
AddForeignKey.new(**to_h)
end
|
#to_sql(_version) ⇒ Object
74
75
76
77
78
|
# File 'lib/pg_trunk/operations/foreign_keys/drop_foreign_key.rb', line 74
def to_sql(_version)
sql = "ALTER TABLE #{table.to_sql} DROP CONSTRAINT"
sql << " IF EXISTS" if if_exists
sql << " #{name.lean.inspect};"
end
|