github.com/supabase/cli@v1.168.1/internal/db/dump/templates/dump_data.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  # Disable triggers so that data dump can be restored exactly as it is
    11  echo "SET session_replication_role = replica;
    12  "
    13  
    14  # Explanation of pg_dump flags:
    15  #
    16  #   --exclude-schema omit data from internal schemas as they are maintained by platform
    17  #   --exclude-table  omit data from migration history tables as they are managed by platform
    18  #   --column-inserts only column insert syntax is supported, ie. no copy from stdin
    19  #   --schema '*'     include all other schemas by default
    20  #
    21  # Never delete SQL comments because multiline records may begin with them.
    22  pg_dump \
    23      --data-only \
    24      --quote-all-identifier \
    25      --exclude-schema "${EXCLUDED_SCHEMAS:-}" \
    26      --exclude-table "auth.schema_migrations" \
    27      --exclude-table "storage.migrations" \
    28      --exclude-table "supabase_functions.migrations" \
    29      --schema "$INCLUDED_SCHEMAS" \
    30      ${EXTRA_FLAGS:-}
    31  
    32  # Reset session config generated by pg_dump
    33  echo "RESET ALL;"