module ActiveRecord::Mysql::Awesome::SchemaDumper

Private Instance Methods

table(table, stream) click to toggle source
Calls superclass method
# File lib/activerecord-mysql-awesome/active_record/schema_dumper.rb, line 9
def table(table, stream)
  @types = @types.merge(@connection.options_for_column_spec(table))
  pk = @connection.primary_key(table)
  pkcol = @connection.columns(table).detect { |c| c.name == pk }
  pkcolspec = @connection.column_spec_for_primary_key(pkcol, @types) if pkcol
  table_options = @connection.table_options(table)

  buf = StringIO.new
  super(table, buf)
  buf = buf.string
  buf.sub!(/(?=, force: (?:true|:cascade))/, pkcolspec.map {|key, value| ", #{key}: #{value}"}.join) if pkcolspec
  buf.sub!(/(?= do \|t\|)/, ", options: #{table_options.inspect}") if table_options
  stream.print buf
  stream
ensure
  @types = @connection.native_database_types
end