Skip to content

Add local Postgres bootstrap and diagnostics for native macOS development #80

Description

@ncolesummers

Summary

Local LoopWorks development assumes postgres://loopworks:loopworks@127.0.0.1:5432/loopworks, but the repo does not provide a first-class native Postgres bootstrap or diagnostic path. This repeatedly causes seed/browser-validation work to fall back to fixtures or fail with low-level connection errors.

RCA from issue #37 validation

  • .env.local does not set DATABASE_URL, so the app and seed script use the repo default from src/db/client.ts / scripts/seed-demo-data.ts.
  • Native Postgres is installed through Postgres.app and was listening on 127.0.0.1:5432.
  • Unsandboxed readiness check: pg_isready -h 127.0.0.1 -p 5432 returned accepting connections.
  • Default LoopWorks connection failed: FATAL: role "loopworks" does not exist.
  • Local catalog check showed role_loopworks=false and db_loopworks=false.
  • In sandboxed runs the same problem can appear as ECONNREFUSED or Operation not permitted, which makes the root cause less obvious.

Impact

  • bun run db:seed:reset cannot seed a native local Postgres unless the developer manually creates the expected role/database.
  • bun run dev:fixture and bun run build log DB read failures and use fixture/unavailable fallbacks, which blocks seeded-DB browser evidence.
  • The README says seed after database bootstrap, but there is no native macOS/Postgres.app bootstrap or doctor command in the repo.

Proposed scope

Add a local DB bootstrap/doctor path rather than expanding issue #37.

Acceptance criteria

  1. Document native macOS/Postgres.app setup for the default LoopWorks URL, including exact commands to create the loopworks role/database and run migrations/seeding.
  2. Add a non-destructive db:doctor or equivalent that checks server reachability, configured host, expected role, expected database, and migration readiness without printing secrets.
  3. Add an explicit local bootstrap command or documented manual commands for creating the default local role/database.
  4. Improve bun run db:seed / bun run db:seed:reset failures so missing role, missing database, and server-unreachable cases print actionable next steps.
  5. Preserve ADR 0007 safety: no production writes, no non-loopback bootstrap/seed writes, and no secret leakage in logs.
  6. Add focused script tests for URL parsing, diagnostics, and failure-message behavior.

Notes

This is distinct from #70, which owns Neon/Vercel production and preview database wiring. This issue is for local native Postgres developer setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:docsProduct, architecture, ADR, and contributor documentation.area:infraCI, deployment, databases, and local development infrastructure.bugSomething isn't workingloop:developmentDevelopment loop work.priority:p2Important but not immediately blocking.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions