Conflict-free schema version handling
This is a follow-up to #212051 (closed) to further reduce merge conflicts caused by the schema version information in db/structure.sql
.
This targets the list of migrations that have been executed to reach the currently present database schema. Essentially the information in schema_migrations
which is populated at the end of db/structure.sql
.
The conflicts originate from appending to a sorted list of schema versions. The proposal here is to do the following instead:
- When a migration executes, it touches a file in
db/schema_migrations/$schema_version
(or whatever directory), one file per migration -
db/structure.sql
contains the following to populate the tableschema_migrations
:
INSERT INTO schema_migrations (version) SELECT pg_ls_dir('db/schema_migrations');
This essentially removes the append-only style and leads to no conflicts anymore.