Skip to content

Commit b44cb1b

Browse files
authored
WEB-129 Use DIRECT_URL for migrations, update docs (#119)
2 parents 6bc2de5 + 717c65f commit b44cb1b

4 files changed

Lines changed: 31 additions & 10 deletions

File tree

.env.example

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public"
2-
SUPABASE_URL="http://localhost:54321"
3-
SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXXXXXXXX"
1+
# Postgres (pooled) connection string
2+
# Used by the application layer, and should be configured to use connection pooling (pgbouncer) in prod
3+
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres"
4+
5+
# Postgres direct connection string
6+
# Used by Prisma for migrations
7+
DIRECT_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres"
8+
9+
# Supabase project URL
10+
SUPABASE_URL="http://127.0.0.1:54321"
11+
12+
# Supabase anonymous (public) key
13+
SUPABASE_ANON_KEY="sb_publishable_XXX"
14+
15+
# Supabase service role key
16+
# Secret key, never expose to the client
17+
SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXX"

.github/workflows/ci-cd.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ jobs:
2222
- name: Install dependencies
2323
run: npm ci
2424

25-
- name: Generate Prisma Client
26-
run: npx prisma generate
27-
2825
- name: Lint
2926
run: npm run lint
3027

docs/SUPABASE_SETUP.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,23 @@ These credentials are also accessible again via `npx supabase status` if you nee
4747

4848
### 2. Configure environment variables
4949

50-
In your `.env` copy the "Project URL" to `SUPABASE_URL`, and the "Secret" to `SUPABASE_SERVICE_ROLE_KEY`.
50+
Copy `.env.example` to `.env` and fill in the credentials from the output above:
5151

52-
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.
52+
| Variable | Source |
53+
| --- | --- |
54+
| `DATABASE_URL` | Database "URL" — used by the application layer (configure connection pooling via pgbouncer in prod) |
55+
| `DIRECT_URL` | Database "URL" — used by Prisma for migrations (direct connection, no pooling) |
56+
| `SUPABASE_URL` | "Project URL" |
57+
| `SUPABASE_ANON_KEY` | "Publishable" key |
58+
| `SUPABASE_SERVICE_ROLE_KEY` | "Secret" key (**never expose to the client**) |
59+
60+
> Locally there is no connection pooling, so `DATABASE_URL` and `DIRECT_URL` will be the same.
5361
5462
```env
55-
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public"
63+
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres"
64+
DIRECT_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres"
5665
SUPABASE_URL="http://127.0.0.1:54321"
66+
SUPABASE_ANON_KEY="sb_publishable_XXXXXXXXX"
5767
SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXXXXXXXX"
5868
```
5969

prisma.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export default defineConfig({
88
seed: "tsx prisma/seed.ts",
99
},
1010
datasource: {
11-
url: process.env.DATABASE_URL,
11+
url: process.env.DIRECT_URL ?? "",
1212
},
1313
});

0 commit comments

Comments
 (0)