aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_dumper.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-10-08 09:04:50 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-10-08 09:04:50 +0900
commit72bf3ded097f1c492f00bd07c9148ef0bf1d3973 (patch)
treeef733f3f47e28cea179285d8f39a548ef59934c6 /activerecord/lib/active_record/schema_dumper.rb
parent0fc115724b87f7b4c990dc26d8b42f48ae72dfeb (diff)
downloadrails-72bf3ded097f1c492f00bd07c9148ef0bf1d3973.tar.gz
rails-72bf3ded097f1c492f00bd07c9148ef0bf1d3973.tar.bz2
rails-72bf3ded097f1c492f00bd07c9148ef0bf1d3973.zip
Prevent to create blank comment
Currently blank comment does not dump to `db/schema.rb`. But created it even if specified blank.
Diffstat (limited to 'activerecord/lib/active_record/schema_dumper.rb')
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index ab2d64e903..41fed004a0 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -128,9 +128,7 @@ HEADER
table_options = @connection.table_options(table)
if table_options.present?
- table_options.each do |key, value|
- tbl.print ", #{key}: #{value.inspect}" if value.present?
- end
+ tbl.print ", #{format_options(table_options)}"
end
tbl.puts " do |t|"
@@ -237,6 +235,10 @@ HEADER
end
end
+ def format_options(options)
+ options.map { |key, value| "#{key}: #{value.inspect}" if value }.compact.join(", ")
+ end
+
def remove_prefix_and_suffix(table)
table.gsub(/^(#{@options[:table_name_prefix]})(.+)(#{@options[:table_name_suffix]})$/, "\\2")
end