diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-12-05 12:13:49 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-12-05 12:13:49 -0800 |
commit | 0c692f4d121792117b6a71e5ed590a31c3b9d12e (patch) | |
tree | 869bf3fb884e55847bf7aa34b4c6b463d1590720 /activerecord/lib/active_record/schema_dumper.rb | |
parent | 2e299fca715b083a60222a85e48f9d3b8dd8ce93 (diff) | |
parent | 94ef7b515b9bd026a0ed67ef7dabbf0b4ab554e3 (diff) | |
download | rails-0c692f4d121792117b6a71e5ed590a31c3b9d12e.tar.gz rails-0c692f4d121792117b6a71e5ed590a31c3b9d12e.tar.bz2 rails-0c692f4d121792117b6a71e5ed590a31c3b9d12e.zip |
Merge branch 'joshsusser-master' into merge
* joshsusser-master:
style cleanup
Add migration history to schema.rb dump
Add metadata to schema_migrations
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/schema.rb
Diffstat (limited to 'activerecord/lib/active_record/schema_dumper.rb')
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 36bde44e7c..73c0f5b9eb 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -24,6 +24,7 @@ module ActiveRecord def dump(stream) header(stream) + migrations(stream) tables(stream) trailer(stream) stream @@ -44,7 +45,7 @@ module ActiveRecord stream.puts "# encoding: #{stream.external_encoding.name}" end - stream.puts <<HEADER + header_text = <<HEADER_RUBY # 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 # incrementally modify your database, and then regenerate this schema definition. @@ -59,13 +60,25 @@ module ActiveRecord ActiveRecord::Schema.define(#{define_params}) do -HEADER +HEADER_RUBY + stream.puts header_text end def trailer(stream) stream.puts "end" end + def migrations(stream) + all_migrations = ActiveRecord::SchemaMigration.all.to_a + if all_migrations.any? + stream.puts(" migrations do") + all_migrations.each do |migration| + stream.puts(migration.schema_line(" ")) + end + stream.puts(" end") + end + end + def tables(stream) @connection.tables.sort.each do |tbl| next if ['schema_migrations', ignore_tables].flatten.any? do |ignored| |