mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #26258 from kamipo/remove_unnecessary_format_string
Remove unnecessary `format_string`
This commit is contained in:
commit
3df9876a24
1 changed files with 2 additions and 15 deletions
|
@ -145,22 +145,9 @@ HEADER
|
|||
# find all migration keys used in this table
|
||||
keys = @connection.migration_keys
|
||||
|
||||
# figure out the lengths for each column based on above keys
|
||||
lengths = [0] * keys.length
|
||||
|
||||
# the string we're going to sprintf our values against, with standardized column widths
|
||||
format_string = ["%s"] * keys.length
|
||||
|
||||
# add column type definition to our format string
|
||||
format_string.unshift " t.%s "
|
||||
|
||||
format_string *= ""
|
||||
|
||||
column_specs.each do |colspec|
|
||||
values = keys.zip(lengths).map { |key, len| colspec.key?(key) ? colspec[key] + ", " : " " * len }
|
||||
values.unshift colspec[:type]
|
||||
tbl.print((format_string % values).gsub(/,\s*$/, ""))
|
||||
tbl.puts
|
||||
values = keys.map { |key| colspec[key] }.compact
|
||||
tbl.puts " t.#{colspec[:type]} #{values.join(", ")}"
|
||||
end
|
||||
|
||||
indexes_in_create(table, tbl)
|
||||
|
|
Loading…
Reference in a new issue