Module: ActiveRecord::ConnectionAdapters::ColumnDumper

Defined in:
lib/activerecord-mysql-unsigned/active_record/v4/connection_adapters/abstract/schema_dumper.rb,
lib/activerecord-mysql-unsigned/active_record/v4_1/connection_adapters/abstract/schema_dumper.rb

Instance Method Summary collapse

Instance Method Details

#migration_keysObject

Lists the valid migration options



29
30
31
# File 'lib/activerecord-mysql-unsigned/active_record/v4/connection_adapters/abstract/schema_dumper.rb', line 29

def migration_keys
  [:name, :limit, :precision, :unsigned, :scale, :default, :null]
end

#prepare_column_options(column, types) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/activerecord-mysql-unsigned/active_record/v4/connection_adapters/abstract/schema_dumper.rb', line 8

def prepare_column_options(column, types)
  spec = {}
  #binding.pry if column.name.include?("ip")
  spec[:name]      = column.name.inspect

  # AR has an optimization which handles zero-scale decimals as integers. This
  # code ensures that the dumper still dumps the column as a decimal.
  spec[:type]      = if column.type == :integer && /^(numeric|decimal)/ =~ column.sql_type
                       'decimal'
                     else
                       column.type.to_s
                     end
  spec[:limit]     = column.limit.inspect if column.limit != types[column.type][:limit] && spec[:type] != 'decimal'
  spec[:precision] = column.precision.inspect if column.precision
  spec[:scale]     = column.scale.inspect if column.scale
  spec[:null]      = 'false' unless column.null
  spec[:unsigned]  = 'true' if column.unsigned
  spec[:default]   = default_string(column.default) if column.has_default?
  spec
end