github.com/supabase/cli@v1.168.1/internal/db/dump/templates/dump_role.sh (about) 1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 export PGHOST="$PGHOST" 5 export PGPORT="$PGPORT" 6 export PGUSER="$PGUSER" 7 export PGPASSWORD="$PGPASSWORD" 8 export PGDATABASE="$PGDATABASE" 9 10 # Explanation of pg_dumpall flags: 11 # 12 # --roles-only only include create, alter, and grant role statements 13 # 14 # Explanation of sed substitutions: 15 # 16 # - do not create or alter reserved roles as they are blocked by supautils 17 # - explicitly allow altering safe attributes, ie. statement_timeout, pgrst.* 18 # - discard role attributes that require superuser, ie. nosuperuser, noreplication 19 # - do not alter membership grants by supabase_admin role 20 pg_dumpall \ 21 --roles-only \ 22 --quote-all-identifier \ 23 --no-role-passwords \ 24 --no-comments \ 25 | sed -E "s/^CREATE ROLE \"($RESERVED_ROLES)\"/-- &/" \ 26 | sed -E "s/^ALTER ROLE \"($RESERVED_ROLES)\"/-- &/" \ 27 | sed -E "s/ (NOSUPERUSER|NOREPLICATION)//g" \ 28 | sed -E "s/^-- (.* SET \"($ALLOWED_CONFIGS)\" .*)/\1/" \ 29 | sed -E "s/GRANT \".*\" TO \"($RESERVED_ROLES)\"/-- &/" \ 30 | sed -E "${EXTRA_SED:-}" \ 31 | uniq 32 33 # Reset session config generated by pg_dump 34 echo "RESET ALL;"