Files

10 lines
674 B
Bash
Executable File

#!/usr/bin/env bash
# Creates the role and database the tests expect on a PostgreSQL you already run.
# The application role must NOT be a superuser and must NOT have BYPASSRLS, or row-level security is skipped.
# Usage: PGHOST=localhost PGPORT=5432 PGUSER=postgres ./scripts/setup-postgres.sh
set -euo pipefail
psql -v ON_ERROR_STOP=1 -c "create role app login password 'app' nosuperuser nobypassrls"
psql -v ON_ERROR_STOP=1 -c "create database tenantdemo owner app"
echo "Done. Tests connect to \${PG_URL:-jdbc:postgresql://localhost:5433/tenantdemo} as app/app."
echo "The superuser comparison in 03-isolation connects as 'postgres' with an empty password (trust auth)."