db/scripts/common.sh

28 lines
481 B
Bash
Raw Permalink Normal View History

2023-07-17 19:44:40 +00:00
#! /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
}
2023-07-20 18:03:07 +00:00
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
}