debian-mirror-gitlab/scripts/schema_changed.sh

26 lines
789 B
Bash
Raw Normal View History

2018-11-20 20:47:30 +05:30
#!/bin/sh
schema_changed() {
2020-04-22 19:07:51 +05:30
if [ ! -z "$(git diff --name-only -- db/structure.sql)" ]; then
2020-05-24 23:13:21 +05:30
printf "Schema changes are not cleanly committed to db/structure.sql\n"
2018-11-20 20:47:30 +05:30
printf "The diff is as follows:\n"
2020-04-22 19:07:51 +05:30
diff=$(git diff -p --binary -- db/structure.sql)
2018-11-20 20:47:30 +05:30
printf "%s" "$diff"
2018-03-17 18:26:18 +05:30
exit 1
else
2020-05-24 23:13:21 +05:30
printf "Schema changes are correctly applied to db/structure.sql\n"
2018-03-17 18:26:18 +05:30
fi
2020-10-24 23:57:45 +05:30
if [ ! -z "$(git add -A -n db/schema_migrations)" ]; then
printf "Schema version files have not been committed to the repository:\n"
printf "The following files should be committed:\n"
diff=$(git add -A -n db/schema_migrations)
printf "%s" "$diff"
exit 2
else
printf "Schema changes are correctly applied to db/structure.sql and db/schema_migrations/\n"
fi
2018-03-17 18:26:18 +05:30
}
schema_changed