postgres: Support using a custom database name in reindex script
Created by: caugustus-sourcegraph
If POSTGRES_DB is set to a custom value, a new Postgres container exits with:
pgsql | reindexdb: error: could not connect to database sg: FATAL: database "sg" does not exist
This changes the reindex script so it correctly loads the PGDATABASE environment variable (ref: https://www.postgresql.org/docs/12/app-reindexdb.html).
Example docker-compose:
pgsql:
container_name: pgsql
image: 'index.docker.io/sourcegraph/postgres-12.6-alpine:insiders@sha256:695eaa5070a879863597b077c610129685a7ab4e8ac0039864b7aad3dfc5cf5b'
environment:
- POSTGRES_DB=demo