lfittl / activerecord-clean-db-structure

Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
BSD 3-Clause "New" or "Revised" License
146 stars 36 forks source link

Merge conflicts on schema_migrations values #14

Closed nvanoorschot closed 5 years ago

nvanoorschot commented 5 years ago

Hi, nice gem! The only thing we constantly run into is merge conflicts of branches when 2 people added new database migrations. At the bottom of the structure.sql there will be different versions which end with a semicolon.

The versions are currently listed as follows:

INSERT INTO "schema_migrations" (version) VALUES
('20190503120501'),
('20190506124902'),
('20190508123941'),
('20190508132644');

I think we can prevent a lot of merge conflicts if we uglify this a bit:

INSERT INTO "schema_migrations" (version) VALUES
 ('20190503120501')
,('20190506124902')
,('20190508123941')
,('20190508132644')
;

Let me know what you think. I can create a PR for this if you like.

nvanoorschot commented 5 years ago

Plus always sorting the versions alphabetically can also fix a number of common mistakes we see in practice.