github.com/Redstoneguy129/cli@v0.0.0-20230211220159-15dca4e91917/internal/db/dump/templates/dump_schema.sh (about) 1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 # Explanation of pg_dump flags: 5 # 6 # --schema-only omit data like migration history, pgsodium key, etc. 7 # --exclude-schema omit internal schemas as they are maintained by platform 8 # --no-comments only object owner can set comment, omit to allow restore by non-superuser 9 # --extension '*' prevents event triggers from being dumped, bash escaped with single quote 10 # 11 # Explanation of sed substitutions: 12 # 13 # - do not alter superuser role "supabase_admin" 14 # - do not include ACL changes on internal schemas 15 # - do not include RLS policies on cron extension schema 16 # 17 # TODO: 18 # - support pg_dumpall --roles-only 19 pg_dump \ 20 --schema-only \ 21 --quote-all-identifier \ 22 --exclude-schema "$EXCLUDED_SCHEMAS" \ 23 --extension '*' \ 24 --no-comments \ 25 --dbname "$DB_URL" \ 26 | sed -E 's/^ALTER DEFAULT PRIVILEGES FOR ROLE "supabase_admin"/-- &/' \ 27 | sed -E "s/^GRANT (.+) ON (.+) \"($EXCLUDED_SCHEMAS)\"/-- &/" \ 28 | sed -E "s/^REVOKE (.+) ON (.+) \"($EXCLUDED_SCHEMAS)\"/-- &/" \ 29 | sed -E 's/^CREATE POLICY "cron_job_/-- &/' \ 30 | sed -E 's/^ALTER TABLE "cron"/-- &/' 31 32 # Reset session config generated by pg_dump 33 echo "RESET ALL;"