Switch trailing commas in structure.sql to leading#43414
Switch trailing commas in structure.sql to leading#43414mlarraz wants to merge 2 commits intorails:mainfrom
Conversation
|
@eileencodes this might help a lot with the merge conflict question you had. |
|
That's an interesting solution to the problem. There's a couple things we need to do though before we can merge this.
|
Done
We're running this internally as a monkey patch and aside from the one-time cost of the first structure dump changing all the existing entries, it's been pretty invisible. |
|
Interesting indeed! While that definitely means the same thing to the computer, it feels like a (small) experience downgrade for the human (who I think will still need to edit this section to resolve conflicts, at least sometimes, even with the spurious semicolon changes removed). What if we reversed the sort order instead? 🤔 |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Tested this monkey patch: # https://github.com/rails/rails/pull/43414
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter
def insert_versions_sql(versions)
if versions.is_a?(Array)
super(versions.reverse)
else
super
end
end
end
end
endIt seems to work pretty well. Edit: after running that monkey patch for about a month, I've made a PR to upstream: #44363 |
This was suggested as a better fix in rails#43414. The goal is to decrease merge conflicts that often come at the bottom due to the semi colon placement. We've been running with a monkey patch for it for about a month, and can confirm, it's definitely an improvement. So I'm making this as an alternative suggestion to rails#43414 Adding @mlarraz as a co-author - thanks for the original inspiration. Co-authored-by: @mlarraz <[email protected]>
This was suggested as a better fix in rails#43414. The goal is to decrease merge conflicts that often come at the bottom due to the semi colon placement. We've been running with a monkey patch for it for about a month, and can confirm, it's definitely an improvement. So I'm making this as an alternative suggestion to rails#43414 Adding @mlarraz as a co-author - thanks for the original inspiration. Co-authored-by: @mlarraz <[email protected]>
Summary
Changes the formatting of the migration versions to reduce merge conflicts.
Today every new migration added adds a new line here, but also requires moving the semicolon from what was previously the most recent line:
INSERT INTO "schema_migrations" (version) VALUES ('20190924183850'), ('20191008165610'), +('20191108235701'), -('20191108235701'); +('20191118181905');This leads to merge conflicts if lots of migrations are being added at the same. By changing the formatting slightly, this is no longer an issue:
INSERT INTO "schema_migrations" (version) VALUES ('20190924183850') ,('20191008165610') ,('20191108235701') +,('20191118181905') ;In both cases this is valid SQL with no functional difference.