a tool for shared writing and social publishing
README.md
# schema-drift Compare the catalog of production, the long-lived local Supabase stack, and a throwaway database built only from `supabase/migrations`. ```bash # prod (read-only) vs local stack; writes scripts/schema-drift/snapshots/{prod,local}.json node --env-file=.env.local scripts/schema-drift/drift.mjs check # what the migrations alone produce (docker; same image as the local stack) node scripts/schema-drift/fresh.mjs up node scripts/schema-drift/drift.mjs snapshot fresh /tmp/fresh.json node scripts/schema-drift/drift.mjs diff scripts/schema-drift/snapshots/prod.json /tmp/fresh.json node scripts/schema-drift/fresh.mjs down # print prod's definition of an object, for writing a catch-up migration node --env-file=.env.local scripts/schema-drift/drift.mjs defs prod index public.facts_entity_idx # kinds: function | index | view | trigger | policy | constraint (keys as printed in the diff) ``` Targets: `prod` = `DB_URL`, `local` = `LOCAL_DB_URL` or `127.0.0.1:54322`, `fresh` = `FRESH_DB_URL` or `127.0.0.1:54399`, or the name of any env var that holds a connection string. In a diff, `-` is only in the first snapshot, `+` only in the second, `~` in both but different. Exit code is 1 when there are differences. ## Safety Every session sets `default_transaction_read_only = on` and runs inside `BEGIN READ ONLY`, and only reads `pg_catalog` / `information_schema`, `pg_settings`, role settings, `storage.buckets` metadata, `cron.job` metadata and `supabase_migrations.schema_migrations`. No app rows are read. Connection strings are never printed. Role/database settings whose name looks secret (`*secret*`, `*key*`, `*token*`, `*password*`, `*jwt*`) are stored as `<masked:hash>` so a change still shows up. Function bodies, view definitions and cron commands are stored as hashes; use `defs` to see a body. ## What's captured Postgres version; extensions; plan-relevant `pg_settings`; role and database settings (`pgrst.*`, `statement_timeout`, ...); app-schema tables, columns (type/default/nullability/identity/generate…