提交 72bf3ded 编写于 作者: R Ryuta Kamizono

Prevent to create blank comment

Currently blank comment does not dump to `db/schema.rb`. But created it
even if specified blank.
上级 0fc11572
......@@ -284,10 +284,10 @@ def create_table(table_name, comment: nil, **options)
end
if supports_comments? && !supports_comments_in_create?
change_table_comment(table_name, comment) if comment
change_table_comment(table_name, comment) if comment.present?
td.columns.each do |column|
change_column_comment(table_name, column.name, column.comment) if column.comment
change_column_comment(table_name, column.name, column.comment) if column.comment.present?
end
end
......
......@@ -509,7 +509,7 @@ def add_index(table_name, column_name, options = {}) #:nodoc:
end
def add_sql_comment!(sql, comment) # :nodoc:
sql << " COMMENT #{quote(comment)}" if comment
sql << " COMMENT #{quote(comment)}" if comment.present?
sql
end
......
......@@ -128,9 +128,7 @@ def table(table, stream)
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 @@ def foreign_keys(table, stream)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册