Add rake task to check db schema is valid

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2017-09-19 15:58:25 +03:00
parent b7cd589709
commit 9cd0d68fe9
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
2 changed files with 16 additions and 0 deletions

View file

@ -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

10
scripts/schema_changed.sh Normal file
View file

@ -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