Skip to content

Run against a real Postgres when POSTGRES_URL is set - #14

Merged
kamath merged 1 commit into
mainfrom
create-pull-request
Jul 27, 2026
Merged

Run against a real Postgres when POSTGRES_URL is set#14
kamath merged 1 commit into
mainfrom
create-pull-request

Conversation

@kamath

@kamath kamath commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

src/db.ts now picks its backend at open time: postgres + drizzle-orm/postgres-js when POSTGRES_URL is set, and the existing embedded PGlite otherwise, so local dev stays zero-config while a deployment can point at a shared server. The handle owns its own close and migrate, which keeps the data-dir ownership guard, the signal/beforeExit hooks and migrateDb working on either backend — callers still import one db, and the now-unused pg export is gone.

drizzle.config.ts follows the same switch so db:generate and db:studio target whichever backend is configured, both db scripts load the workspace-root .env, db:migrate is reachable from the repo root, and migrate.ts logs where it is migrating (password stripped). vite.config.ts keeps postgres external alongside PGlite since it is a Node driver.

Unrelated drive-by: sidebar.tsx's skeleton width was Math.random(), a server/client hydration mismatch, and is now fixed at 70%.

🤖 Generated with Claude Code

PGlite stays the zero-config local default, but it can't be shared across
processes and doesn't survive a deploy. `src/db.ts` now picks a backend at
open time: `postgres` + `drizzle-orm/postgres-js` when `POSTGRES_URL` is
set, embedded PGlite otherwise. The handle owns its own close and migrate,
so the data-dir ownership guard, the signal hooks and `migrateDb` all keep
working either way, and callers still import one `db`.

`drizzle.config.ts` follows the same switch so `db:generate`/`db:studio`
point at whichever backend is configured, and both db scripts now load the
workspace-root .env. `db:migrate` is reachable from the root and logs where
it is migrating.

Also drops the `Math.random()` skeleton width in `sidebar.tsx`, which was a
server/client hydration mismatch.

Co-Authored-By: Claude <noreply@anthropic.com>
@kamath
kamath merged commit 6db4e86 into main Jul 27, 2026
1 check passed
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