From 494cfc373577850957844363a472ecd9c106f30a Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Thu, 27 Dec 2012 21:50:55 +0000 Subject: [PATCH] Fix missing ending newline in db structure dump: When dumping database structure with `rake db:structure:dump` and using migrations, the resulting file will not end with a newline char. Although it's not mandatory, it breaks a lot of simple use cases with programs like cat, more, grep, etc. This changes use `puts' instead of `<<' to append migration versions data to the dump and also split the line where this is happening as it was a bit long. --- activerecord/lib/active_record/railties/databases.rake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index b25c0270c2..259d0ff12b 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -300,7 +300,9 @@ db_namespace = namespace :db do end if ActiveRecord::Base.connection.supports_migrations? - File.open(filename, "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } + File.open(filename, "a") do |f| + f.puts ActiveRecord::Base.connection.dump_schema_information + end end db_namespace['structure:dump'].reenable end