Module: Code0::ZeroTrack::Database::MigrationHelpers::ConstraintHelpers

Included in:
Code0::ZeroTrack::Database::Migration::V1_0
Defined in:
lib/code0/zero_track/database/migration_helpers/constraint_helpers.rb

Instance Method Summary collapse

Instance Method Details

#check_constraint_name(table, column, type) ⇒ Object



12
13
14
15
16
17
# File 'lib/code0/zero_track/database/migration_helpers/constraint_helpers.rb', line 12

def check_constraint_name(table, column, type)
  identifier = "#{table}_#{column}_check_#{type}"
  hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10)

  "check_#{hashed_identifier}"
end

#text_limit_name(table, column, name: nil) ⇒ Object



8
9
10
# File 'lib/code0/zero_track/database/migration_helpers/constraint_helpers.rb', line 8

def text_limit_name(table, column, name: nil)
  name.presence || check_constraint_name(table, column, 'max_length')
end