File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change
1
+ * The table columns inside ` schema.rb ` are now sorted alphabetically.
2
+
3
+ Previously they'd be sorted by creation order, which can cause merge conflicts when two
4
+ branches modify the same table concurrently.
5
+
6
+ * John Duff*
7
+
1
8
* Introduce versions formatter for the schema dumper.
2
9
3
10
It is now possible to override how schema dumper formats versions information inside the
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ def table(table, stream)
192
192
tbl . puts ", force: :cascade do |t|"
193
193
194
194
# then dump all non-primary key columns
195
- columns . each do |column |
195
+ columns . sort_by ( & :name ) . each do |column |
196
196
raise StandardError , "Unknown type '#{ column . sql_type } ' for column '#{ column . name } '" unless @connection . valid_type? ( column . type )
197
197
next if column . name == pk
198
198
Original file line number Diff line number Diff line change @@ -167,6 +167,14 @@ def test_schema_dump_with_regexp_ignored_table
167
167
assert_no_match %r{create_table "ar_internal_metadata"} , output
168
168
end
169
169
170
+ def test_table_columns_sorted
171
+ column_names = column_definition_lines ( dump_table_schema ( "companies" ) ) . flatten . filter_map do |line |
172
+ $1 if line !~ /t\. index/ && line . match ( /t\. .*"(\w +)"/ )
173
+ end
174
+
175
+ assert_equal %w[ account_id client_of description firm_id firm_name name rating status type ] , column_names
176
+ end
177
+
170
178
def test_schema_dumps_index_columns_in_right_order
171
179
index_definition = dump_table_schema ( "companies" ) . split ( /\n / ) . grep ( /t\. index.*company_index/ ) . first . strip
172
180
if current_adapter? ( :Mysql2Adapter , :TrilogyAdapter )
You can’t perform that action at this time.
0 commit comments