Class: ActiveRecord::ConnectionAdapters::MySQL::TableDefinition

Inherits:
TableDefinition show all
Includes:
ColumnMethods
Defined in:
activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb

Instance Attribute Summary

Attributes inherited from TableDefinition

#as, #comment, #foreign_keys, #indexes, #name, #options, #temporary

Instance Method Summary collapse

Methods included from ColumnMethods

#blob, #json, #longblob, #longtext, #mediumblob, #mediumtext, #primary_key, #tinyblob, #tinytext, #unsigned_bigint, #unsigned_decimal, #unsigned_float, #unsigned_integer

Methods inherited from TableDefinition

#[], #column, #columns, #foreign_key, #index, #initialize, #primary_keys, #references, #remove_column, #timestamps

Methods included from ColumnMethods

#primary_key

Constructor Details

This class inherits a constructor from ActiveRecord::ConnectionAdapters::TableDefinition

Instance Method Details

#new_column_definition(name, type, options) ⇒ Object

:nodoc:


66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb', line 66

def new_column_definition(name, type, options) # :nodoc:
  column = super
  case column.type
  when :primary_key
    column.type = :integer
    column.auto_increment = true
  when /\Aunsigned_(?<type>.+)\z/
    column.type = $~[:type].to_sym
    column.unsigned = true
  end
  column.unsigned ||= options[:unsigned]
  column.charset = options[:charset]
  column
end