Files
loki/scripts
Mao NakamotoandClaude Opus 4.7 9b80cc9137 chore(db): extend migration toolkit to OrangeCat / Supabase + both-on-one-host
Same job, one more source. Now the toolkit handles:
- FleetCrown out of Neon (`dump-from-neon.sh`)
- OrangeCat out of Supabase (`dump-from-supabase.sh`)
- Both consolidated onto one self-hosted Postgres box

scripts/db/dump-from-supabase.sh
  Mirrors dump-from-neon.sh's interface. Supabase-specific guards:
  - Refuses pooler URLs (port 6543 / pooler.supabase.com) because
    pg_dump fails midway through transaction-pooled connections.
  - Defaults to --schema=public only. Supabase's auth/storage/realtime/
    extensions schemas would create dangling-role FK errors on a vanilla
    Postgres target. FULL_DUMP=1 dumps everything when self-hosting
    gotrue too (bigger project for another day).
  - Same .sql + .manifest.txt output shape as the Neon script;
    restore-to-target.sh accepts either without modification.

scripts/db/BOTH_PRODUCTS_ONE_HOST.md
  Layers two databases (`fleetcrown`, `orangecat`) on a single Postgres
  instance with separate roles and per-role pg_hba.conf lines. Covers:
  - role + database setup
  - pg_hba rules: each role authenticates only to its own DB
  - migration sequence: FleetCrown first (it's broken), OrangeCat
    second (still functional on Supabase)
  - auth-stays-on-Supabase recommendation for OrangeCat (cheap, no
    gotrue self-host needed at this scale)
  - shared backup cron with off-box rsync mirror
  - PgBouncer add-on for when connection count balloons
  - explicit "when to split the box" thresholds (sustained 70% CPU,
    <95% cache hit ratio, p95 latency >50ms)

scripts/db/README.md
  Updated header + file table to mention both products. Migration
  cookbook now has separate Step 1 entries for Neon vs Supabase and
  points at BOTH_PRODUCTS_ONE_HOST.md for the dual-product path.

Capacity sanity for the curious: a Hetzner CX22 (€4.51/mo, 2 vCPU, 4 GB
RAM, 40 GB SSD) is over-provisioned by ~3 orders of magnitude for both
products at today's scale (single-user each). Upgrade in-place to CX32
when sustained CPU exceeds 70% — that's many months out.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 09:04:53 +02:00
..