Skip to content

Latest commit

 

History

History
74 lines (54 loc) · 2.87 KB

DATABASE.md

File metadata and controls

74 lines (54 loc) · 2.87 KB

Fossall Postgres

Fossall reads five-letter English words from Fly.io Managed Postgres cluster postgreputest (q49ypo4wvmzr17ln, region fra). The cluster is shared with other apps in the org. Fossall data lives only in:

Database fossall
Schema words (five-letter list) and shop (simulated store)
Table words.five_letter_words; shop tables in SHOP.md
App user fossall (MPG role writer)

Do not create a second MPG cluster, add a Fly volume, allocate a dedicated IPv4, or raise min_machines_running. Do not paste fly mpg status --json (it prints credentials) into chat, commits, or issues.

Word list: data/five_letter_words.txt, filtered from ENABLE 1.0 (public domain): lowercase ASCII [a-z]{5} only.

One-time setup

fly mpg databases create q49ypo4wvmzr17ln -n fossall
fly mpg users create q49ypo4wvmzr17ln -u fossall -r writer

# Schema (psql via platform auth — no URL in the shell history)
fly mpg connect q49ypo4wvmzr17ln -d fossall < db/001_init.sql
fly mpg connect q49ypo4wvmzr17ln -d fossall < db/002_shop.sql

# Seed. Proxy first, then set DATABASE_URL to the fossall database
# on localhost (pooled or direct). Never commit the URL.
fly mpg proxy q49ypo4wvmzr17ln
export DATABASE_URL='postgres://…@localhost:16380/fossall'
make seed

# Inject DATABASE_URL on the Fly app (restarts Machines).
fly mpg attach q49ypo4wvmzr17ln -a fossall -d fossall -u fossall

Local /words

Postgres is not on the public internet. Other pages work without a database.

fly mpg proxy q49ypo4wvmzr17ln
export DATABASE_URL='postgres://…@localhost:16380/fossall'
make dev
# http://localhost:8080/words

If DATABASE_URL is unset, the server still starts; /words and /shop return 503 with an explanation. /health never touches Postgres. Simulated shop setup: SHOP.md.

Earth database (second database on the same cluster)

Deep-time globe data lives in a separate database on the same cluster. Do not create a second cluster. Do not fly mpg attach this database (attach rewrites DATABASE_URL used by /words).

Database earth
Schema earth
App user earth (MPG role writer)
App env EARTH_DATABASE_URL
./scripts/earth-mpg-setup.sh
# or:
# fly mpg databases create q49ypo4wvmzr17ln -n earth
# fly mpg users create q49ypo4wvmzr17ln -u earth -r writer
# fly mpg connect q49ypo4wvmzr17ln -d earth < db/earth/001_init.sql

fly mpg proxy q49ypo4wvmzr17ln
export EARTH_DATABASE_URL='postgres://…@localhost:16380/earth'
make seed-earth

Set EARTH_DATABASE_URL on the Fly app with fly secrets set (not attach). Sources, licenses, and API: EARTH.md.

If EARTH_DATABASE_URL is unset, /earth still renders; /api/earth/* returns 503. /health never touches Postgres.