Skip to content

praefect: Track database schema in Git

Patrick Steinhardt requested to merge pks-praefect-dump-database into master

Given that our Praefect database schema is seeded by migrations, there is no single place which gives an overview over the complete schema. While this is information that can be easily obtained by connecting to a Praefect database, this workaround doesn't really work across different Praefect versions given that one would have to re-seed the database for each version one is about to investigate. This makes it hard to get info about the current database schema and to compare changes to the schema between different versions.

Introduce a new script "generate-praefect-schema" to fix this issue. The script connects to a Postgres server, creates a new database, seeds the database by executing praefect sql-migrate and then dumps the resulting schema. Furthermore, a new Makefile target automates this and writes the dump into our _support directory.

The intent is that whenever the database changes, the author of those changes must update the schema in our _support folder such that it's easily possible to diff the schema across different versions in our Git history. To ensure that this happens, a new CI job is added which performs the dump and then checks that no changes occurred.

Edited by Patrick Steinhardt

Merge request reports