Skip to content

Commit

Permalink
allow user defined role for start-client (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
olirice authored Oct 15, 2024
1 parent 725ffa3 commit f904736
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nix/tools/run-client.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
PSQL_VERSION="15"
MIGRATION_FILE=""
PORTNO="@PGSQL_DEFAULT_PORT@"
PSQL_USER="postgres"

# Function to display help
print_help() {
Expand All @@ -15,6 +16,7 @@ print_help() {
echo "Options:"
echo " -v, --version [15|16|orioledb-16] Specify the PostgreSQL version to use (required)"
echo " -f, --file FILE Provide a custom migration script"
echo " -u, --user USER Specify the user/role to use (default: postgres)"
echo " -h, --help Show this help message"
echo
echo "Description:"
Expand All @@ -29,6 +31,7 @@ print_help() {
echo " nix run .#start-client -- --version 15"
echo " nix run .#start-client -- --version 16 --file custom_migration.sql"
echo " nix run .#start-client -- --version 16 --port 5433"
echo " nix run .#start-client -- --version 16 --user supabase_admin"
}

# Parse arguments
Expand All @@ -52,6 +55,15 @@ while [[ "$#" -gt 0 ]]; do
exit 1
fi
;;
-u|--user)
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
PSQL_USER="$2"
shift 2
else
echo "Error: --user requires an argument"
exit 1
fi
;;
-h|--help)
print_help
exit 0
Expand Down Expand Up @@ -137,4 +149,4 @@ fi
# psql -v ON_ERROR_STOP=1 --no-password --no-psqlrc -U supabase_admin -p "$PORTNO" -h localhost -c 'SELECT extensions.pg_stat_statements_reset(); SELECT pg_stat_reset();' postgres || true

# Start interactive psql session
exec psql -U postgres -p "$PORTNO" -h localhost postgres
exec psql -U "$PSQL_USER" -p "$PORTNO" -h localhost postgres

0 comments on commit f904736

Please sign in to comment.