Permalink
Browse files

use the schema migration model to dump schema info

  • Loading branch information...
1 parent ff5c385 commit d0bb43d621c471659d03504f48f0197c0ae3b57c @tenderlove tenderlove committed Jan 13, 2012
@@ -1,4 +1,5 @@
require 'active_support/deprecation/reporting'
+require 'active_record/schema_migration'
module ActiveRecord
module ConnectionAdapters # :nodoc:
@@ -404,8 +405,10 @@ def structure_dump
def dump_schema_information #:nodoc:
sm_table = ActiveRecord::Migrator.schema_migrations_table_name
- migrated = select_values("SELECT version FROM #{sm_table} ORDER BY version")
- migrated.map { |v| "INSERT INTO #{sm_table} (version) VALUES ('#{v}');" }.join("\n\n")
+
+ ActiveRecord::SchemaMigration.order('version').all.map { |sm|
+ "INSERT INTO #{sm_table} (version) VALUES ('#{sm.version}');"
+ }.join "\n\n"
end
# Should not be called normally, but this operation is non-destructive.
@@ -1,4 +1,6 @@
-require 'active_record'
+require 'active_record/scoping/default'
+require 'active_record/scoping/named'
+require 'active_record/base'
module ActiveRecord
class SchemaMigration < ActiveRecord::Base

0 comments on commit d0bb43d

Please sign in to comment.