class PGTrunk::Operations::CheckConstraints::Base

@abstract @private Base class for operations with check constraints

Public Instance Methods

<=>(other) click to toggle source

By default foreign keys are sorted by tables and names.

Calls superclass method PGTrunk::Operation#<=>
# File lib/pg_trunk/operations/check_constraints/base.rb, line 23
def <=>(other)
  return unless other.is_a?(self.class)

  result = table <=> other.table
  result.zero? ? super : result
end

Private Instance Methods

custom_name?(qname = name) click to toggle source
# File lib/pg_trunk/operations/check_constraints/base.rb, line 65
def custom_name?(qname = name)
  qname&.differs_from?(/^chk_rails_\w+$/)
end
generated_name() click to toggle source

************************************************************************* Helpers for operation definitions *************************************************************************

# File lib/pg_trunk/operations/check_constraints/base.rb, line 52
def generated_name
  return @generated_name if instance_variable_defined?(:@generated_name)

  @generated_name = begin
    return if table.blank? || expression.blank?

    PGTrunk::QualifiedName.new(
      nil,
      PGTrunk.database.check_constraint_name(table.lean, expression),
    )
  end
end