From 9cd0d68fe90f27ad297317cd8cc5e8f81c2d75a9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 19 Sep 2017 15:58:25 +0300 Subject: [PATCH] Add rake task to check db schema is valid Signed-off-by: Dmitriy Zaporozhets --- .gitlab-ci.yml | 6 ++++++ scripts/schema_changed.sh | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 scripts/schema_changed.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0520f3b1c37..d797fdc4699 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -517,6 +517,12 @@ db:seed_fu-mysql: <<: *db-seed_fu <<: *use-mysql +db:check-schema-pg: + <<: *db-migrate-reset + <<: *use-pg + script: + - source scripts/schema_changed.sh + # Frontend-related jobs gitlab:assets:compile: <<: *dedicated-runner diff --git a/scripts/schema_changed.sh b/scripts/schema_changed.sh new file mode 100644 index 00000000000..5de2b35571d --- /dev/null +++ b/scripts/schema_changed.sh @@ -0,0 +1,10 @@ +function schema_changed() { + if [[ ! -z `git diff --name-only -- db/schema.rb` ]]; then + echo "db/schema.rb after rake db:migrate:reset is different from one in the repository" + exit 1 + else + echo "db/schema.rb after rake db:migrate:reset matches one in the repository" + fi +} + +schema_changed