mirror of
https://github.com/block/buzz.git
synced 2026-11-02 23:41:08 +00:00
fix(seed): run psql with -X so psqlrc cannot retarget after the local guard
psql -c no longer implies -X, so ~/.psqlrc or PSQLRC (exportable from .env) ran after the guard and could \connect to another host. Pass -X on both the local and Docker psql paths and assert the control invocation carries it. Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -38,15 +38,16 @@ if [[ ! "${PGDATABASE}" =~ ^[A-Za-z0-9_-]+$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -X skips psqlrc, which runs after this guard and could \connect elsewhere.
|
||||
if command -v psql >/dev/null 2>&1; then
|
||||
run_psql() {
|
||||
PGPASSWORD="${PGPASSWORD}" psql -h "${PGHOST}" -p "${PGPORT}" \
|
||||
PGPASSWORD="${PGPASSWORD}" psql -X -h "${PGHOST}" -p "${PGPORT}" \
|
||||
-U "${PGUSER}" -d "${PGDATABASE}" "$@"
|
||||
}
|
||||
elif docker exec buzz-postgres psql --version >/dev/null 2>&1; then
|
||||
run_psql() {
|
||||
docker exec -i -e PGPASSWORD="${PGPASSWORD}" buzz-postgres \
|
||||
psql -U "${PGUSER}" -d "${PGDATABASE}" "$@"
|
||||
psql -X -U "${PGUSER}" -d "${PGDATABASE}" "$@"
|
||||
}
|
||||
else
|
||||
echo "error: neither psql nor buzz-postgres docker psql is available" >&2
|
||||
|
||||
Reference in New Issue
Block a user