pggate
v0.1.0
Published
EXPLAIN every Supabase query at 100,000 synthetic rows before you ship, and prove each fix: Postgres 18 (PGlite) in-process, nothing sent anywhere
Maintainers
Readme
pggate
Run EXPLAIN (ANALYZE, BUFFERS) on every query of your Supabase app at 100,000 rows, before you ship. pggate rebuilds your schema from your migrations (or a schema snapshot) in Postgres 18 running in-process (PGlite, WebAssembly), loads synthetic rows, explains each supabase-js chain and .sql query, and proves each suggested fix by applying it and explaining again. Nothing is sent to a pggate server: there is none.
The same engine runs in the browser at pggate.dev.
Use
npx pggate check # the project in the current directory (where supabase/migrations is), 100k rows
npx pggate check path/to/project # another directory
npx pggate check --format md # the Markdown report (the PR comment)
npx pggate --help # every command and optionExit code: 0 nothing found · 1 a fail finding · 2 something could not be analysed (UNSUPPORTED_*) or needs a license key (LICENSE_REQUIRED). pggate never skips something and exits 0; list a file:line you have read under acknowledge in pggate.config.json to accept it.
Node.js 22 or later.
Tables made in the dashboard
If some tables are not created by any migration, give pggate a snapshot of your schema. It holds definitions, never rows:
npx pggate snapshot --db-url "$DATABASE_URL" # writes supabase/pggate-snapshot.json; reads only the catalog
npx pggate snapshot --print-sql # the same query, to run in the Supabase SQL Editor yourself
npx pggate check --snapshot supabase/pggate-snapshot.jsonThe output of supabase db dump works as a snapshot too, but it has to be passed with --snapshot: it has no pg_dump header, so inside supabase/migrations/ it would run as one more migration.
Free, Rescue, Guard
Free: pggate check on synthetic data, every finding with its proof, and the DDL of the first proven fix in each report. Rescue and Guard keys (pggate.dev) unlock every fix as one migration file (pggate rescue … --out), your real statistics (--dsn, --stats), the diff gate for pull requests (--base) and pggate hook. Without a key a paid feature prints LICENSE_REQUIRED and exits 2.
With a key, the CLI checks it against Lemon Squeezy's License API once per run, with a 7-day offline grace. That request carries the key (and, for an activated machine, its instance id), never your schema, queries, connection string or report.
splinter
The structural layer runs splinter, the linter behind Supabase Advisor, in the sandbox. splinter has no license upstream, so this package does not include it: installing the package downloads splinter.sql from a pinned commit and checks its sha256. If your package manager skips install scripts, run node node_modules/pggate/scripts/fetch-splinter.mjs once, or pass --no-structural.
License
Licensed file by file: most of pggate is FSL-1.1-MIT (LICENSE); the files that implement the paid features are under the pggate Commercial License (LICENSE-COMMERCIAL). LICENSING.md lists which is which. The open-source packages bundled into this package keep their own licenses, in THIRD_PARTY_NOTICES.
