Skip to content

Allow user defined role for start-client #1272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading