Class: PGTrunk::Operations::ForeignKeys::RenameForeignKey
- Inherits:
-
Base
- Object
- PGTrunk::Operation
- Base
- PGTrunk::Operations::ForeignKeys::RenameForeignKey
- Defined in:
- lib/pg_trunk/operations/foreign_keys/rename_foreign_key.rb
Overview
Definition for the rename_foreign_key
operation
Instance Method Summary collapse
Methods inherited from Base
Methods included from PGTrunk::Operation::SQLHelpers
Methods included from PGTrunk::Operation::RubyHelpers
#dump, #to_a, #to_opts, #to_ruby
Methods included from PGTrunk::Operation::Inversion
Methods included from PGTrunk::Operation::Validations
Methods included from PGTrunk::Operation::Attributes
Instance Method Details
#invert ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/pg_trunk/operations/foreign_keys/rename_foreign_key.rb', line 64 def invert self.class.new( **to_h, name: (new_name if custom_name?(new_name)), to: (name if name != current_name), ) end |
#to_sql(_version) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/pg_trunk/operations/foreign_keys/rename_foreign_key.rb', line 56 def to_sql(_version) <<~SQL.squish ALTER TABLE #{table.to_sql} RENAME CONSTRAINT #{name.name.inspect} TO #{new_name.name.inspect}; SQL end |