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

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

Overview

Active Record MySQL Adapter Table Definition

Instance Attribute Summary collapse

Attributes inherited from TableDefinition

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

Instance Method Summary collapse

Methods inherited from TableDefinition

#[], #check_constraint, #column, #columns, #foreign_key, #index, #new_check_constraint_definition, #new_foreign_key_definition, #primary_keys, #references, #remove_column, #set_primary_key, #timestamps

Methods included from ColumnMethods

#primary_key

Constructor Details

#initialize(conn, name, charset: nil, collation: nil) ⇒ TableDefinition

Returns a new instance of TableDefinition.



66
67
68
69
70
# File 'lib/active_record/connection_adapters/mysql/schema_definitions.rb', line 66

def initialize(conn, name, charset: nil, collation: nil, **)
  super
  @charset = charset
  @collation = collation
end

Instance Attribute Details

#charsetObject (readonly)

Returns the value of attribute charset.



64
65
66
# File 'lib/active_record/connection_adapters/mysql/schema_definitions.rb', line 64

def charset
  @charset
end

#collationObject (readonly)

Returns the value of attribute collation.



64
65
66
# File 'lib/active_record/connection_adapters/mysql/schema_definitions.rb', line 64

def collation
  @collation
end

Instance Method Details

#new_column_definition(name, type, **options) ⇒ Object

:nodoc:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/active_record/connection_adapters/mysql/schema_definitions.rb', line 72

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

  super
end