Skip to content

Make production Postgres durable and migrated#22

Merged
OziinG merged 1 commit intomainfrom
fix/db-migrations-ebs
Apr 30, 2026
Merged

Make production Postgres durable and migrated#22
OziinG merged 1 commit intomainfrom
fix/db-migrations-ebs

Conversation

@OziinG
Copy link
Copy Markdown
Contributor

@OziinG OziinG commented Apr 30, 2026

Summary

  • add the initial Prisma migration for the delivery operations schema
  • add a Docker migrator target/service and run it before app rollout in the EC2 deploy script
  • bind Postgres data to POSTGRES_DATA_DIR, defaulting EC2 deploys to /mnt/tomotono-postgres/data

Root cause

Production Postgres was running, but the database had no app tables. SSM confirmed psql \dt returned Did not find any relations., so CSV upload had nowhere to persist route/import records.

EBS

Created and mounted a dedicated encrypted gp3 EBS volume for Postgres data:

  • volume: vol-0d7847d66a798e0e5
  • mount: /mnt/tomotono-postgres
  • data dir: /mnt/tomotono-postgres/data

Verification

  • bash -n scripts/ec2-bootstrap-and-deploy.sh
  • docker compose config --quiet
  • npx prisma validate
  • docker build --target migrator -t tomotono-route-console-migrator:local-test .
  • disposable Docker Postgres + docker compose run --rm migrate applied 20260430070000_init and created 9 tables
  • npm test
  • npm run lint
  • npm run build

Refs #21

Run Prisma migrations as part of the EC2 Docker Compose rollout and bind Postgres data to the EBS mount path so upload data has tables and persists outside the container lifecycle.\n\nConstraint: Production DB was online but empty; psql \dt returned no relations, and the requested storage target is EBS-backed Postgres data.\nRejected: Manual database patching only | future deploys would recreate the same missing-schema failure.\nConfidence: high\nScope-risk: moderate\nDirective: Keep Postgres data on /mnt/tomotono-postgres/data for EC2 unless an explicit POSTGRES_DATA_DIR override is supplied.\nTested: bash -n scripts/ec2-bootstrap-and-deploy.sh; docker compose config --quiet; npx prisma validate; docker build --target migrator -t tomotono-route-console-migrator:local-test .; docker compose migrator applied 20260430070000_init to a disposable Postgres and produced 9 tables; npm test; npm run lint; npm run build\nNot-tested: Live EC2 redeploy after this commit pending main merge.\n\nCo-authored-by: OmX <omx@oh-my-codex.dev>
@OziinG OziinG merged commit eaa714f into main Apr 30, 2026
2 checks passed
@OziinG OziinG deleted the fix/db-migrations-ebs branch April 30, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant