Skip to content

feat(api): Postgres persistence via DATABASE_URL (Neon)#28

Open
kuyacarlo wants to merge 2 commits into
canaryfrom
feat/api-postgres-url
Open

feat(api): Postgres persistence via DATABASE_URL (Neon)#28
kuyacarlo wants to merge 2 commits into
canaryfrom
feat/api-postgres-url

Conversation

@kuyacarlo

Copy link
Copy Markdown
Contributor

Summary

  • Nest /users, /teams, /tasks, /activities now read Postgres through a pg Pool on DATABASE_URL — works with a direct URL or a PgBouncer/Neon pooler URL. When unset, endpoints fall back to @worksight/common fixtures, so the offline demo path is unchanged.
  • New apps/api/sql/001_core.sql (employees/teams/assignments/activities, CHECKs matching common types) and pnpm --filter @worksight/api seed (idempotent, applies schema + loads fixtures).
  • Fixture/schema fixes so data actually survives a real database: fake hex employee ids → real UUIDs, manager_id: ''/'admin'null/super-admin UUID, duplicate internal_ids renumbered, team ids now pass Zod v4 uuid checks. manager_id is nullable; assignment employee_id/source_id are uuids.
  • Live Neon project worksight (jolly-bar-28285215, ap-southeast-1) created and seeded. DATABASE_URL (pooler) + DATABASE_URL_DIRECT pushed to all three Vercel envs of worksight-api. The old Supabase host in Vercel env no longer resolves — documented in docs/handoffs/2026-07-26-api-postgres.md.

Test plan

  • pnpm --filter @worksight/api type-check / lint / build green
  • pnpm --filter @worksight/api test — 10 passed (fixture fallback path)
  • Seeded Neon via direct URL: 15 employees, 5 teams, 8 assignments, 14 activities
  • Booted dist against the Neon pooler; /users and /tasks return DB rows (verified by updating a row in SQL and seeing the response change)
  • Vercel preview deploy picks up DATABASE_URL

Made with Cursor

The old Supabase host in Vercel env no longer resolves and no DATABASE_URL
existed anywhere, so the API could never leave fixtures. Add a pg Pool
service that accepts a direct Postgres or PgBouncer/Neon pooler URL,
a repository mapping rows to @worksight/common types, and a seed script
that applies sql/001_core.sql and loads the shared fixtures. Endpoints
fall back to fixtures when DATABASE_URL is unset, so the offline demo
path keeps working.

Fix fixture data that could never round-trip a real database: fake hex
employee ids, empty/'admin' manager_id values, duplicate internal_ids on
system accounts, and team ids that fail Zod v4 uuid version checks.
manager_id is now nullable and assignment employee/source ids are uuids.

Live Neon project (jolly-bar-28285215) is seeded; credentials stay in
gitignored .env.local and Vercel env.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worksight-docs Ready Ready Preview, Comment Jul 25, 2026 6:53pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
worksight Skipped Skipped Jul 25, 2026 6:53pm
worksight-api Skipped Skipped Jul 25, 2026 6:53pm

… root

Co-authored-by: Cursor <cursoragent@cursor.com>
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