diff options
Diffstat (limited to 'activerecord/lib/active_record/schema_dumper.rb')
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 794a354917..e30b481fe1 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -24,7 +24,6 @@ module ActiveRecord def dump(stream) header(stream) - migrations(stream) tables(stream) trailer(stream) stream @@ -35,9 +34,12 @@ module ActiveRecord def initialize(connection) @connection = connection @types = @connection.native_database_types + @version = Migrator::current_version rescue nil end def header(stream) + define_params = @version ? ":version => #{@version}" : "" + stream.puts <<HEADER # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to @@ -51,7 +53,7 @@ module ActiveRecord # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define do +ActiveRecord::Schema.define(#{define_params}) do HEADER end @@ -60,16 +62,6 @@ HEADER stream.puts "end" end - def migrations(stream) - rows = @connection.select_all("SELECT * FROM #{@connection.quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)}") - rows.each do |migration| - line = %Q( migration "#{migration['version']}") - line << %Q(, "#{migration['name']}") unless migration['name'].blank? - stream.puts line - end - stream.puts "" - end - def tables(stream) @connection.tables.sort.each do |tbl| next if ['schema_migrations', ignore_tables].flatten.any? do |ignored| |