Module: SqliteCrypto::MigrationHelpers::References

Defined in:
lib/sqlite_crypto/migration_helpers.rb

Instance Method Summary collapse

Instance Method Details

#references(*args, **options) ⇒ Object Also known as: belongs_to



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sqlite_crypto/migration_helpers.rb', line 18

def references(*args, **options)
  ref_name = args.first
  ref_table = options.delete(:to_table) || ref_name.to_s.pluralize

  if (primary_key_type = detect_primary_key_type(ref_table))
    options[:type] ||= :string
    options[:limit] ||= (primary_key_type == :uuid) ? 36 : 26
  end

  super
end