diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-11-23 15:43:41 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-11-30 13:28:47 +0300 |
commit | dc54c84f07f83852a33d5140eb3c46a0d9139dfb (patch) | |
tree | ed13f3795c5434ce03d8388818f267a942ad74c5 /Makefile | |
parent | 1df76cd4ecf6c640389b05e5910793786281b930 (diff) |
praefect: Track database schema in Git
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 the schema is always up to date, a new CI job is added
which performs the dump and then checks that no changes occurred.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -449,6 +449,11 @@ no-proto-changes: | ${BUILD_DIR} ${Q}${GIT} diff -- '*.pb.go' 'ruby/proto/gitaly' >${BUILD_DIR}/proto.diff ${Q}if [ -s ${BUILD_DIR}/proto.diff ]; then echo "There is a difference in generated proto files. Please take a look at ${BUILD_DIR}/proto.diff file." && exit 1; fi +.PHONY: dump-database-schema +## Dump the clean database schema of Praefect into a file. +dump-database-schema: build + ${Q}"${SOURCE_DIR}"/_support/generate-praefect-schema >"${SOURCE_DIR}"/_support/praefect-schema.sql + .PHONY: smoke-test smoke-test: TEST_PACKAGES := ${SOURCE_DIR}/internal/gitaly/rubyserver smoke-test: all rspec |