Module: SchemaPlus::ActiveRecord::ConnectionAdapters::AbstractAdapter::VisitTableDefinition

Defined in:
lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:


244
245
246
# File 'lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb', line 244

def self.included(base) #:nodoc:
  base.alias_method_chain :visit_TableDefinition, :schema_plus
end

Instance Method Details

#visit_TableDefinition_with_schema_plus(o) ⇒ Object

:nodoc:


248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb', line 248

def visit_TableDefinition_with_schema_plus(o) #:nodoc:
  create_sql = visit_TableDefinition_without_schema_plus(o)
  last_chunk = ") #{o.options}"

  unless create_sql.end_with?(last_chunk)
    raise "Internal Error: Can't find '#{last_chunk}' at end of '#{create_sql}' - Rails internals have changed!"
  end

  unless o.foreign_keys.empty?
    create_sql[create_sql.size - last_chunk.size, 0] = ', ' + o.foreign_keys.map(&:to_sql) * ', '
  end
  create_sql
end