Run against a real Postgres when POSTGRES_URL is set - #14
Merged
Conversation
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>
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.
src/db.tsnow picks its backend at open time:postgres+drizzle-orm/postgres-jswhenPOSTGRES_URLis 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 owncloseandmigrate, which keeps the data-dir ownership guard, the signal/beforeExithooks andmigrateDbworking on either backend — callers still import onedb, and the now-unusedpgexport is gone.drizzle.config.tsfollows the same switch sodb:generateanddb:studiotarget whichever backend is configured, both db scripts load the workspace-root.env,db:migrateis reachable from the repo root, andmigrate.tslogs where it is migrating (password stripped).vite.config.tskeepspostgresexternal alongside PGlite since it is a Node driver.Unrelated drive-by:
sidebar.tsx's skeleton width wasMath.random(), a server/client hydration mismatch, and is now fixed at 70%.🤖 Generated with Claude Code