Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-23 15:43:41 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-30 13:28:47 +0300
commitdc54c84f07f83852a33d5140eb3c46a0d9139dfb (patch)
treeed13f3795c5434ce03d8388818f267a942ad74c5 /.gitlab-ci.yml
parent1df76cd4ecf6c640389b05e5910793786281b930 (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 '.gitlab-ci.yml')
-rw-r--r--.gitlab-ci.yml18
1 files changed, 18 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9ff92d543..dc05f9935 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -217,6 +217,24 @@ verify:
- proto/go/gitalypb/*
when: on_failure
+dbschema:
+ <<: *cache_definition
+ stage: test
+ services:
+ # The database version we use must match the version of `pg_dump` we have
+ # available in the build image.
+ - postgres:11.13-alpine
+ variables:
+ <<: *postgres_variables
+ before_script:
+ - while ! psql -h $PGHOST -U $PGUSER -c 'SELECT 1' > /dev/null; do echo "awaiting Postgres service to be ready..." && sleep 1 ; done && echo "Postgres service is ready!"
+ script:
+ - make dump-database-schema no-changes
+ artifacts:
+ paths:
+ - _support/praefect-schema.sql
+ when: on_failure
+
gosec-sast:
before_script:
- apk add pkgconfig libgit2-dev gcc libc-dev