Skip to content

Commit fa645bb

Browse files
authored
fix: allow direct postgres in production (#27)
1 parent 88866c7 commit fa645bb

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Compatibility-first REST API for Tanzania location data backed by PostgreSQL and
3333
3. Start PostgreSQL and update your connection strings if needed.
3434

3535
- Local and test environments use a direct PostgreSQL `DATABASE_URL`.
36-
- Production uses a Prisma Accelerate `DATABASE_URL`.
37-
- If you run `pnpm db:migrate` against an Accelerate-backed environment, also provide `DIRECT_DATABASE_URL` so the migration bootstrap can talk to Postgres directly.
36+
- Production can use either a direct PostgreSQL `DATABASE_URL` or a Prisma Accelerate `DATABASE_URL`.
37+
- If `DATABASE_URL` points at Prisma Accelerate, also provide `DIRECT_DATABASE_URL` so migrations can talk to Postgres directly.
3838

3939
4. Apply the checked-in schema and seed deterministic fixture data.
4040

@@ -70,7 +70,8 @@ pnpm openapi:json
7070
- On a fresh database it bootstraps the historical `init` migration, marks that baseline as applied, and then deploys later migrations
7171
- On an existing database that already has the older Prisma migration history, it only applies the new additive migrations
7272
- Prefer `pnpm db:migrate` over calling `prisma migrate deploy` directly
73-
- `DATABASE_URL` may point at Prisma Accelerate in production, but `pnpm db:migrate` still requires a direct Postgres URL in `DIRECT_DATABASE_URL`
73+
- `DATABASE_URL` may point at direct Postgres or Prisma Accelerate
74+
- If `DATABASE_URL` points at Prisma Accelerate, `pnpm db:migrate` still requires a direct Postgres URL in `DIRECT_DATABASE_URL`
7475

7576
## Testing
7677

src/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ const env = envSchema.parse(process.env);
1919
const usesAccelerate = isAccelerateUrl(env.DATABASE_URL);
2020
const directDatabaseUrl = env.DIRECT_DATABASE_URL ?? (usesAccelerate ? undefined : env.DATABASE_URL);
2121

22-
if (env.NODE_ENV === 'production' && !usesAccelerate) {
23-
throw new Error('Production requires DATABASE_URL to be a Prisma Accelerate URL.');
24-
}
25-
2622
if (env.NODE_ENV !== 'production' && !directDatabaseUrl) {
2723
throw new Error('Non-production requires a direct PostgreSQL URL via DIRECT_DATABASE_URL or DATABASE_URL.');
2824
}

0 commit comments

Comments
 (0)