This commit is contained in:
+10
-4
@@ -21,10 +21,13 @@
|
||||
set -eu
|
||||
|
||||
DB_HOST="${DB_HOST:-db}"
|
||||
DB_USER="${DB_USER:-computer}"
|
||||
DB_NAME="${DB_NAME:-computer}"
|
||||
DB_USER="${DB_USER:-superbrain}"
|
||||
DB_NAME="${DB_NAME:-superbrain}"
|
||||
MIGRATIONS="${MIGRATIONS:-/db/migrations}"
|
||||
[ -n "${PGPASSWORD:-}" ] || { echo "error: PGPASSWORD is required" >&2; exit 1; }
|
||||
[ -n "${PGPASSWORD:-}" ] || {
|
||||
echo "error: PGPASSWORD is required" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
psql() {
|
||||
command psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" -v ON_ERROR_STOP=1 "$@"
|
||||
@@ -67,7 +70,10 @@ for entry in $(psql -Atc "SELECT name || ':' || checksum FROM _migration"); do
|
||||
done
|
||||
|
||||
for f in "$MIGRATIONS"/*.sql; do
|
||||
[ -e "$f" ] || { echo "error: no migrations found in $MIGRATIONS" >&2; exit 1; }
|
||||
[ -e "$f" ] || {
|
||||
echo "error: no migrations found in $MIGRATIONS" >&2
|
||||
exit 1
|
||||
}
|
||||
name="$(basename "$f")"
|
||||
sum="$(sha256sum "$f" | cut -d' ' -f1)"
|
||||
recorded="$(psql -Atc "SELECT checksum FROM _migration WHERE name='$name'")"
|
||||
|
||||
Reference in New Issue
Block a user