From ea02849227b1bc6970f30a1fd60f8287e847e277 Mon Sep 17 00:00:00 2001 From: wlenig <30681316+wlenig@users.noreply.github.com> Date: Fri, 27 Mar 2026 20:58:25 -0400 Subject: [PATCH 1/2] WEB-129 Use `DIRECT_URL` for migrations, update docs --- .env.example | 20 +++++++++++++++++--- docs/SUPABASE_SETUP.md | 16 +++++++++++++--- prisma.config.ts | 4 ++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index b5d456da..a2bdd303 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,17 @@ -DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public" -SUPABASE_URL="http://localhost:54321" -SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXXXXXXXX" \ No newline at end of file +# Postgres (pooled) connection string +# Used by the application layer, and should be configured to use connection pooling (pgbouncer) in prod +DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres" + +# Postgres direct connection string +# Used by Prisma for migrations +DIRECT_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres" + +# Supabase project URL +SUPABASE_URL="http://127.0.0.1:54321" + +# Supabase anonymous (public) key +SUPABASE_ANON_KEY="sb_publishable_XXX" + +# Supabase service role key +# Secret key, never expose to the client +SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXX" \ No newline at end of file diff --git a/docs/SUPABASE_SETUP.md b/docs/SUPABASE_SETUP.md index f4f6baae..ea02b356 100644 --- a/docs/SUPABASE_SETUP.md +++ b/docs/SUPABASE_SETUP.md @@ -47,13 +47,23 @@ These credentials are also accessible again via `npx supabase status` if you nee ### 2. Configure environment variables -In your `.env` copy the "Project URL" to `SUPABASE_URL`, and the "Secret" to `SUPABASE_SERVICE_ROLE_KEY`. +Copy `.env.example` to `.env` and fill in the credentials from the output above: -For `DATABASE_URL`, you may use a locally managed instance, or use the Database "URL". Append `?schema=public` to ensure Prisma uses the public schema. +| Variable | Source | +| --- | --- | +| `DATABASE_URL` | Database "URL" — used by the application layer (configure connection pooling via pgbouncer in prod) | +| `DIRECT_URL` | Database "URL" — used by Prisma for migrations (direct connection, no pooling) | +| `SUPABASE_URL` | "Project URL" | +| `SUPABASE_ANON_KEY` | "Publishable" key | +| `SUPABASE_SERVICE_ROLE_KEY` | "Secret" key (**never expose to the client**) | + +> Locally there is no connection pooling, so `DATABASE_URL` and `DIRECT_URL` will be the same. ```env -DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public" +DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres" +DIRECT_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres" SUPABASE_URL="http://127.0.0.1:54321" +SUPABASE_ANON_KEY="sb_publishable_XXXXXXXXX" SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXXXXXXXX" ``` diff --git a/prisma.config.ts b/prisma.config.ts index fe058b6b..f31b0e31 100644 --- a/prisma.config.ts +++ b/prisma.config.ts @@ -1,5 +1,5 @@ import "dotenv/config"; -import { defineConfig } from "prisma/config"; +import { defineConfig, env } from "prisma/config"; export default defineConfig({ schema: "prisma/schema.prisma", @@ -8,6 +8,6 @@ export default defineConfig({ seed: "tsx prisma/seed.ts", }, datasource: { - url: process.env.DATABASE_URL, + url: env("DIRECT_URL"), }, }); From 717c65f1a57ecdb51755b1cf51190670c0fcf540 Mon Sep 17 00:00:00 2001 From: wlenig <30681316+wlenig@users.noreply.github.com> Date: Sat, 28 Mar 2026 15:00:06 -0400 Subject: [PATCH 2/2] WEB-129 Remove redundant prisma generate step from CI, update config not to raise when DIRECT_URL is not set --- .github/workflows/ci-cd.yml | 3 --- prisma.config.ts | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 87a5ebdb..d000bdd9 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -22,9 +22,6 @@ jobs: - name: Install dependencies run: npm ci - - name: Generate Prisma Client - run: npx prisma generate - - name: Lint run: npm run lint diff --git a/prisma.config.ts b/prisma.config.ts index f31b0e31..7fdb1a9b 100644 --- a/prisma.config.ts +++ b/prisma.config.ts @@ -1,5 +1,5 @@ import "dotenv/config"; -import { defineConfig, env } from "prisma/config"; +import { defineConfig } from "prisma/config"; export default defineConfig({ schema: "prisma/schema.prisma", @@ -8,6 +8,6 @@ export default defineConfig({ seed: "tsx prisma/seed.ts", }, datasource: { - url: env("DIRECT_URL"), + url: process.env.DIRECT_URL ?? "", }, });