Glossary

pg_dump

pg_dump is PostgreSQL's native command-line tool that produces a logical backup of a database — its schema, data, or both — as a SQL script or archive file.

pg_dump is PostgreSQL's native command-line tool that produces a logical backup of a single database as either a plain SQL script or a compressed archive. It reads the catalog and emits the CREATE statements plus COPY/INSERT data needed to rebuild that database elsewhere.

A typical schema-only dump looks like this:

pg_dump \
  --schema-only \
  --no-owner \
  "postgresql://postgres:pass@db.ref.supabase.co:5432/postgres" \
  > schema.sql

pg_dump is a compiled binary. It cannot run in a browser, and it cannot run inside a Supabase Edge Function — the Deno runtime there has no PostgreSQL client binaries and no way to shell out to one. Any tool that runs entirely client-side, SupaMigrate included, has no access to it.

Because of that, the schema is reconstructed a different way: by querying information_schema and pg_catalog directly (tables, columns, constraints, indexes, functions, triggers, policies, sequences) and generating the DDL from those results. That approach is called schema replay. The output is close to what pg_dump --schema-only gives you, but it is built from live catalog queries rather than the binary's own formatter, so ordering and a few defaults may differ. After data loads, sequences are re-synced separately — see sequence resync — because a catalog-driven rebuild does not carry the current sequence values the way a full dump does.

Related terms