Real user data in staging is a privacy/compliance risk. If your production database has PII, health data, payment info, or any regulated data, you need to scrub it before developers touch it.
The scrub-before-share pattern:
# 1. Copy prod to a "clean room" staging databasenpx dbdock copydb "$PROD_URL" "$CLEAN_ROOM_URL"# 2. Scrub the clean roompsql "$CLEAN_ROOM_URL" <<'SQL' UPDATE users SET email = 'user' || id || '@example.invalid', phone = NULL, ssn = NULL; UPDATE payment_methods SET card_last4 = '0000'; DELETE FROM audit_logs WHERE created_at < now() - interval '90 days';SQL# 3. Copy the scrubbed clean room to the developer-facing stagingnpx dbdock copydb "$CLEAN_ROOM_URL" "$STAGING_URL"# 4. Clean up the clean roompsql "$CLEAN_ROOM_URL" -c "DROP DATABASE clean_room;"
For individual developers who want to pull latest prod data into their local:
# Pull prod to local oncenpx dbdock copydb "$PROD_URL" "postgresql://localhost:5432/myapp"# Later, refresh from staging instead of prod (less load on prod)npx dbdock copydb "$STAGING_URL" "postgresql://localhost:5432/myapp"