db/scripts/common.sh
Orion Kindel b9dcc2d05b
Some checks failed
migrate-devel / migrate-devel (push) Failing after 4s
migrate-stage / migrate-stage (push) Successful in 6s
gen-migrations / gen-migrations (push) Failing after 6s
fix: scripts
2023-07-20 13:03:21 -05:00

28 lines
481 B
Bash

#! /bin/bash
query_file() {
psql -v ON_ERROR_STOP=1 --single-transaction --quiet "$1" --file="$2" 1>&2
}
query() {
psql -v ON_ERROR_STOP=1 --single-transaction --quiet "$1" --command="$2" 1>&2
}
schema_changed() {
base="$1"
head="$2"
if [[ -z "$head" ]]; then
base="$1~"
head="$1"
fi
schema_changed=$(git diff --quiet "$base" "$head" -- ./schema)
schema_changed_exit=$?
if [[ "$schema_changed_exit" = "1" ]]; then
exit 0
else
exit 1
fi
}