2018-08-30 02:28:15 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
schema_changed() {
|
2020-03-22 11:09:49 -04:00
|
|
|
if [ ! -z "$(git diff --name-only -- db/structure.sql)" ]; then
|
2020-04-29 11:09:58 -04:00
|
|
|
printf "Schema changes are not cleanly committed to db/structure.sql\n"
|
2018-08-30 02:28:15 -04:00
|
|
|
printf "The diff is as follows:\n"
|
2020-03-22 11:09:49 -04:00
|
|
|
diff=$(git diff -p --binary -- db/structure.sql)
|
2018-08-30 02:28:15 -04:00
|
|
|
printf "%s" "$diff"
|
2017-09-19 08:58:25 -04:00
|
|
|
exit 1
|
|
|
|
else
|
2020-04-29 11:09:58 -04:00
|
|
|
printf "Schema changes are correctly applied to db/structure.sql\n"
|
2017-09-19 08:58:25 -04:00
|
|
|
fi
|
2020-07-23 17:09:19 -04:00
|
|
|
|
|
|
|
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
|
2017-09-19 08:58:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
schema_changed
|