feat(api): Postgres persistence via DATABASE_URL (Neon)#28
Open
kuyacarlo wants to merge 2 commits into
Open
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
This was referenced Jul 25, 2026
… root Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/users,/teams,/tasks,/activitiesnow read Postgres through apgPool onDATABASE_URL— works with a direct URL or a PgBouncer/Neon pooler URL. When unset, endpoints fall back to@worksight/commonfixtures, so the offline demo path is unchanged.apps/api/sql/001_core.sql(employees/teams/assignments/activities, CHECKs matching common types) andpnpm --filter @worksight/api seed(idempotent, applies schema + loads fixtures).manager_id: ''/'admin'→null/super-admin UUID, duplicateinternal_ids renumbered, team ids now pass Zod v4 uuid checks.manager_idis nullable; assignmentemployee_id/source_idare uuids.worksight(jolly-bar-28285215, ap-southeast-1) created and seeded.DATABASE_URL(pooler) +DATABASE_URL_DIRECTpushed to all three Vercel envs ofworksight-api. The old Supabase host in Vercel env no longer resolves — documented indocs/handoffs/2026-07-26-api-postgres.md.Test plan
pnpm --filter @worksight/api type-check/lint/buildgreenpnpm --filter @worksight/api test— 10 passed (fixture fallback path)/usersand/tasksreturn DB rows (verified by updating a row in SQL and seeing the response change)DATABASE_URLMade with Cursor