loadahmetseledb
v0.1.0
Published
TEK KOMUT (ONE COMMAND) Postgres/Supabase DB snapshot (schema + RLS + indexes)
Downloads
12
Readme
loadahmetseledb
Snapshot your Postgres/Supabase schema, RLS policies, and indexes to clean JSON with one command.
Features
- Exports one or many schemas (
public,authetc.). - Separate JSON outputs for tables, RLS policies, and indexes.
- SSL on by default; can be disabled for local/self-signed setups.
- Watch mode to rerun snapshots when migrations change.
Install
- Global:
npm install -g ./loadahmetseledb - Project-local:
npm install ./loadahmetseledb --save-devRequires Node 16+.
Quickstart
- Add
DATABASE_URLto.envorbackend/.env(or pass--url). - Run:
npx loadahmetseledb- Outputs land in
db/by default.
CLI Options
--env <path> Default: .env, backend/.env
--out <dir> Output directory (default: db)
--schema <list> Comma-separated schemas (default: public)
--url <DATABASE_URL> Override env var
--no-ssl Disable SSL
--watch Watch migrations and auto-snapshot
--help Show helpExamples:
npx loadahmetseledb --schema public,auth
npx loadahmetseledb --out .ai/db
npx loadahmetseledb --env backend/.env
npx loadahmetseledb --watch --env backend/.envOutput Files
Per schema you get:
snapshot.<schema>.schema.json– tables and columnssnapshot.<schema>.policies.json– RLS policiessnapshot.<schema>.indexes.json– index definitions Each file includesgenerated_atand is formatted with 2-space JSON for easy diffing.
Watch Mode
--watch listens to:
supabase/migrations/**/*.sqlmigrations/**/*.sql
Any add/change/delete triggers a new snapshot. All other flags (--schema, --out, --url, --no-ssl) still apply.
Backup / History
- Snapshots overwrite by design; there is no built-in versioning.
- Best practice: keep the output folder under git and commit changes.
- For timestamped archives:
OUT=backups/$(date +%Y%m%d-%H%M%S) && npx loadahmetseledb --out "$OUT" - In watch mode, consider a dedicated
backups/path plus periodic commits or tar archives.
Troubleshooting
- DATABASE_URL missing: set it in
.env/backend/.envor pass--url. - Connection/timeout issues: check DB reachability and IP allowlist.
- SSL errors: try
--no-sslfor self-signed/local DBs.
Developer Notes
- ESM-only; import paths include file extensions.
- Default SSL config uses
{ rejectUnauthorized: false }for Supabase compatibility. - Output directory is created if absent and files are overwritten on each run.
