github.com/supabase/cli@v1.168.1/tools/dump_initial_schema.sh (about)

     1  #!/usr/bin/env bash
     2  set -euo pipefail
     3  
     4  # pg_dumpall -d "$DB_URL" -gf global.sql --no-role-passwords
     5  
     6  # Explanation of special flags:
     7  #
     8  #   --column-inserts  include migration history, but not pgsodium key
     9  pg_dump \
    10      --column-inserts \
    11      --exclude-table-data 'pgsodium.key' \
    12      -d 'postgres://supabase_admin:postgres@127.0.0.1:54322/postgres' \
    13  | sed 's/^CREATE SCHEMA /CREATE SCHEMA IF NOT EXISTS /' \
    14  | sed 's/^CREATE TABLE /CREATE TABLE IF NOT EXISTS /' \
    15  | sed 's/^CREATE SEQUENCE /CREATE SEQUENCE IF NOT EXISTS /' \
    16  | sed 's/^CREATE VIEW /CREATE OR REPLACE VIEW /' \
    17  | sed 's/^CREATE FUNCTION /CREATE OR REPLACE FUNCTION /' \
    18  | sed 's/^GRANT ALL ON FUNCTION graphql_public./-- GRANT ALL ON FUNCTION graphql_public./'
    19  
    20  echo "DROP EXTENSION pg_graphql; CREATE EXTENSION pg_graphql WITH SCHEMA graphql;"
    21  
    22  # Reset session config generated by pg_dump
    23  echo "RESET ALL;"