> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tuturuuu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Production database network access design

> A phased plan for restricting production PostgreSQL access and granting temporary access for approved jobs.

## Current evidence and scope

The [backup workflow](https://docs.tuturuuu.com/build/devops/supabase-backup-export.md) uses a read-only SQL snapshot and a separate Storage API copy, then validates a restore. The production migration workflow is a separate privileged database consumer. Cloudflare workloads can use Hyperdrive on the target architecture, but a binding alone does not establish a fixed production egress identity. Treat the deployed allowlist, source addresses, connection modes and project settings as inventory items to verify through the approved control plane.

The allowlist covers PostgreSQL direct and pooler connections. HTTPS Auth, Storage and PostgREST require their own authentication and authorization controls. Include IPv4 and IPv6 where the project supports both. [Supabase network restrictions](https://supabase.com/docs/guides/platform/network-restrictions)

## Delivery phases

1. **Inventory and rehearse.** The database owner records each runtime, migration workflow, export runner, monitor and emergency path, including endpoint, connection mode, observed egress, role, owner and failover. Classify stable service egress, temporary task egress and obsolete access. Test a restriction and restoration of a known-good restrictive policy in staging. Confirm pooler reconnect and cold starts from each admitted runtime. Require a proven stable egress route for any always-on SQL caller before enforcing.
2. **Qualify just-in-time access.** Use a single policy writer with a durable lease ledger. Each request binds the project, job attempt, purpose, approved source address, role and expiry. Permit only the verified runner's narrow address and issue separately scoped, short-lived credentials. Serialize policy changes and preserve the reviewed baseline plus other active leases. Record policy generation, reconcile unknown outcomes against the provider, and release only the completing lease. Reject grants if cleanup cannot be verified. Hosted runner ranges are unsuitable as a standing exception.
3. **Qualify the backup opening.** Bind the temporary IP opening to the reviewed export workflow and use the read-only export role. Open immediately before SQL work and close as soon as the snapshot and dump release their database connections. Exercise failure, cancellation and timeout. Coordinate export limits with snapshot lifetime and verify that the encrypted backup can be restored independently of the opening.
4. **Enforce and observe.** Enable the reviewed baseline only with release-authority approval, a staffed observation window and a verified independent control-plane recovery path. Track connection and pool saturation, denied grants, active lease age, policy drift and backup completion. Restore the captured restrictive baseline on application or workflow regression and retest fresh connections before resuming rollout.

## Acceptance and stop fence

Verify successful new connections through each approved path, rejected new connections outside policy, scoped database roles and parity of HTTPS application calls. Test overlapping grants, duplicate requests, worker restart, a lost provider response and expired grants. Verify whether provider changes close existing connections. Set session and statement limits and prove a separate role/session revocation path bounds access that survives network expiry.

Cap active leases, attempts, control-plane calls and export duration per window. Reserve capacity for cleanup. Persist the stop generation before incident recovery so new grants and retries are denied after restart while cleanup continues. On expiration, a separate reconciler removes the temporary address and verifies policy. If it cannot, alert and revoke the lease credential and terminate its sessions through the approved recovery path. Record only opaque request IDs and outcomes in shared telemetry. Keep the address inventory, credentials, thresholds and emergency access details in restricted custody.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.