Skip to content

Commit f904736

Browse files
authored
allow user defined role for start-client (#1272)
1 parent 725ffa3 commit f904736

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

nix/tools/run-client.sh.in

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
PSQL_VERSION="15"
88
MIGRATION_FILE=""
99
PORTNO="@PGSQL_DEFAULT_PORT@"
10+
PSQL_USER="postgres"
1011

1112
# Function to display help
1213
print_help() {
@@ -15,6 +16,7 @@ print_help() {
1516
echo "Options:"
1617
echo " -v, --version [15|16|orioledb-16] Specify the PostgreSQL version to use (required)"
1718
echo " -f, --file FILE Provide a custom migration script"
19+
echo " -u, --user USER Specify the user/role to use (default: postgres)"
1820
echo " -h, --help Show this help message"
1921
echo
2022
echo "Description:"
@@ -29,6 +31,7 @@ print_help() {
2931
echo " nix run .#start-client -- --version 15"
3032
echo " nix run .#start-client -- --version 16 --file custom_migration.sql"
3133
echo " nix run .#start-client -- --version 16 --port 5433"
34+
echo " nix run .#start-client -- --version 16 --user supabase_admin"
3235
}
3336

3437
# Parse arguments
@@ -52,6 +55,15 @@ while [[ "$#" -gt 0 ]]; do
5255
exit 1
5356
fi
5457
;;
58+
-u|--user)
59+
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
60+
PSQL_USER="$2"
61+
shift 2
62+
else
63+
echo "Error: --user requires an argument"
64+
exit 1
65+
fi
66+
;;
5567
-h|--help)
5668
print_help
5769
exit 0
@@ -137,4 +149,4 @@ fi
137149
# 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
138150

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

0 commit comments

Comments
 (0)