forked from juanscr24/tasklancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprisma.config.ts
More file actions
40 lines (33 loc) · 1.06 KB
/
prisma.config.ts
File metadata and controls
40 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This file was generated by Prisma and assumes you have installed the following:
// npm install --save-dev prisma dotenv
import "dotenv/config";
import { defineConfig, env } from "prisma/config";
// Helper to add SSL and connection pooling parameters to the database URL
const getDatabaseUrl = () => {
const baseUrl = env("DATABASE_URL");
if (!baseUrl) return baseUrl;
// Parse URL to add parameters
const url = new URL(baseUrl);
// Add SSL if not present
if (!url.searchParams.has('sslmode')) {
url.searchParams.set('sslmode', 'require');
}
// Add connection pooling parameters to prevent "too many connections" errors
if (!url.searchParams.has('connection_limit')) {
url.searchParams.set('connection_limit', '5');
}
if (!url.searchParams.has('pool_timeout')) {
url.searchParams.set('pool_timeout', '10');
}
return url.toString();
};
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
seed: `tsx src/lib/prisma.ts`,
},
datasource: {
url: getDatabaseUrl(),
},
});