Class: ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/schema_creation.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ SchemaCreation

Returns a new instance of SchemaCreation.



5
6
7
8
# File 'lib/active_record/connection_adapters/abstract/schema_creation.rb', line 5

def initialize(conn)
  @conn = conn
  @cache = {}
end

Instance Method Details

#accept(o) ⇒ Object



10
11
12
13
# File 'lib/active_record/connection_adapters/abstract/schema_creation.rb', line 10

def accept(o)
  m = @cache[o.class] ||= "visit_#{o.class.name.split('::').last}"
  send m, o
end

#visit_AddColumn(o) ⇒ Object



15
16
17
18
19
# File 'lib/active_record/connection_adapters/abstract/schema_creation.rb', line 15

def visit_AddColumn(o)
  sql_type = type_to_sql(o.type.to_sym, o.limit, o.precision, o.scale)
  sql = "ADD #{quote_column_name(o.name)} #{sql_type}"
  add_column_options!(sql, column_options(o))
end