Class: ActiveRecord::Migration::DefaultSchemaVersionsFormatter
- Defined in:
- activerecord/lib/active_record/migration/default_schema_versions_formatter.rb
Overview
This class is used by the schema dumper to format versions information.
The class receives the current connection
when initialized.
Instance Method Summary collapse
- #format(versions) ⇒ Object
-
#initialize(connection) ⇒ DefaultSchemaVersionsFormatter
constructor
:nodoc:.
Constructor Details
#initialize(connection) ⇒ DefaultSchemaVersionsFormatter
:nodoc:
9 10 11 |
# File 'activerecord/lib/active_record/migration/default_schema_versions_formatter.rb', line 9 def initialize(connection) @connection = connection end |
Instance Method Details
#format(versions) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# 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 |