.env.production.local (bukan di .env shared kalau beda dengan DB lokal).
Docs: neon.com/docs
Env di project
.env.development.local:
Setup Neon (pertama kali)
Buat project
Neon Console → New Project → pilih region (dekat user / Cloudflare)
Ambil connection string
Project Dashboard → tombol Connect → pilih:
- Branch:
main/ production - Connection pooling: ON (hostname berisi
-pooler) — disarankan untuk Workers - Copy string
postgresql://...
Simpan aman
Paste ke
Jangan commit — file ini di-gitignore.
.env.production.local sebagai DATABASE_URL.Jangan commit — file ini di-gitignore.
Pooled vs direct
| Tipe | Kapan dipakai |
|---|---|
Pooled (-pooler di hostname) | Runtime app, Workers via Hyperdrive |
| Direct (tanpa pooler) | Migration berat, psql, tooling satu koneksi panjang |
Verifikasi koneksi
CI/CD (GitHub Actions)
SecretDATABASE_URL di environment production — isi sama dengan Neon production. Script ci-materialize-env.sh menulis ke .env.production.local sebelum deploy.
Troubleshooting
| Masalah | Solusi |
|---|---|
| SSL required | Pastikan ?sslmode=require di URL |
| Too many connections | Pakai pooled URL atau Hyperdrive |
| Migrate gagal di CI | Cek IP allowlist Neon (biasanya open untuk Neon cloud) |
| Doctor DB merah di lokal | Normal jika Postgres lokal belum jalan — override dev URL |