Skip to content

Commit

Permalink
use the schema migration model to dump schema info
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jan 13, 2012
1 parent ff5c385 commit d0bb43d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
@@ -1,4 +1,5 @@
require 'active_support/deprecation/reporting' require 'active_support/deprecation/reporting'
require 'active_record/schema_migration'


module ActiveRecord module ActiveRecord
module ConnectionAdapters # :nodoc: module ConnectionAdapters # :nodoc:
Expand Down Expand Up @@ -404,8 +405,10 @@ def structure_dump


def dump_schema_information #:nodoc: def dump_schema_information #:nodoc:
sm_table = ActiveRecord::Migrator.schema_migrations_table_name 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 end


# Should not be called normally, but this operation is non-destructive. # Should not be called normally, but this operation is non-destructive.
Expand Down
4 changes: 3 additions & 1 deletion activerecord/lib/active_record/schema_migration.rb
@@ -1,4 +1,6 @@
require 'active_record' require 'active_record/scoping/default'
require 'active_record/scoping/named'
require 'active_record/base'


module ActiveRecord module ActiveRecord
class SchemaMigration < ActiveRecord::Base class SchemaMigration < ActiveRecord::Base
Expand Down

0 comments on commit d0bb43d

Please sign in to comment.