Legendary Arena Lab

PostgreSQL Setup

data

Migration in progress. api.legendary-arena.com and PostgreSQL are moving from Render to a self-hosted DigitalOcean Ubuntu host behind Cloudflare. Render remains rollback-ready until decommission phase.

PostgreSQL Setup

Install PostgreSQL 18 locally on the API host, lock network exposure to localhost, create app role/database, and apply baseline tuning for an 8 GB host.

Summary

This page owns infra/scripts/30-postgres.ps1 .

The script:

  • installs PostgreSQL 18
  • enables and starts service
  • enforces localhost-only listen
  • sets initial memory and WAL tuning values
  • creates role and database

Execute

Run as root with explicit database password:

sudo LA_DB_PASSWORD='replace-me' pwsh -File infra/scripts/30-postgres.ps1

Optional overrides:

sudo LA_DB_NAME=la LA_DB_USER=la LA_DB_PASSWORD='replace-me' LA_DB_PORT=5432 pwsh -File infra/scripts/30-postgres.ps1

Verify

sudo systemctl status postgresql --no-pager
sudo -u postgres psql -c "\l"
sudo -u postgres psql -c "\du"
sudo ss -ltnp | grep 5432

Expected:

  • service active
  • role and database exist
  • port 5432 bound only to localhost addresses

Environment contract

Set app connection string using localhost:

DATABASE_URL=postgres://la:replace-me@localhost:5432/la

Safety note

Do not run app builds or migration experiments against production data directly during rehearsal. Always use restored copies until formal cutover.

References

  • Plan section 4.4 postgres-setup page stub
  • Plan section 5.1 database base checklist