Class: ActiveRecord::Mysql::Awesome::TableDefinition

Inherits:
ConnectionAdapters::TableDefinition
  • Object
show all
Includes:
ColumnMethods
Defined in:
lib/activerecord-mysql-awesome/active_record/connection_adapters/abstract_mysql_adapter.rb

Instance Method Summary collapse

Methods included from ColumnMethods

#primary_key, #unsigned_integer

Constructor Details

#initialize(types, name, temporary, options, as = nil) ⇒ TableDefinition

Returns a new instance of TableDefinition.



27
28
29
30
# File 'lib/activerecord-mysql-awesome/active_record/connection_adapters/abstract_mysql_adapter.rb', line 27

def initialize(types, name, temporary, options, as = nil)
  super(types, name, temporary, options)
  @as = as
end

Instance Method Details

#new_column_definition(name, type, options) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/activerecord-mysql-awesome/active_record/connection_adapters/abstract_mysql_adapter.rb', line 32

def new_column_definition(name, type, options)
  column = super
  case column.type
  when :primary_key
    column.type = :integer
    column.auto_increment = true
  when :unsigned_integer
    column.type = :integer
    column.unsigned = true
  end
  column.auto_increment ||= options[:auto_increment]
  column.unsigned ||= options[:unsigned]
  column.charset = options[:charset]
  column.collation = options[:collation]
  column
end