123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::Migration::DefaultSchemaVersionsFormatter

Do not use. This class is for internal use only.

Overview

This class is used by the schema dumper to format versions information.

The class receives the current #connection when initialized.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(connection) ⇒ DefaultSchemaVersionsFormatter

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration/default_schema_versions_formatter.rb', line 9

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connection (readonly, private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration/default_schema_versions_formatter.rb', line 27

attr_reader :connection

Instance Method Details

#format(versions)

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration/default_schema_versions_formatter.rb', line 13

def format(versions)
  sm_table = connection.quote_table_name(connection.pool.schema_migration.table_name)

  if versions.is_a?(Array)
    sql = +"INSERT INTO #{sm_table} (version) VALUES\n"
    sql << versions.reverse.map { |v| "(#{connection.quote(v)})" }.join(",\n")
    sql << ";"
    sql
  else
    "INSERT INTO #{sm_table} (version) VALUES (#{connection.quote(versions)});"
  end
end