-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprisma.config.ts
More file actions
23 lines (21 loc) · 848 Bytes
/
Copy pathprisma.config.ts
File metadata and controls
23 lines (21 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import 'dotenv/config';
import { defineConfig } from 'prisma/config';
// Pin Prisma's migration ledger to the same schema as the generated models.
// Client generation can run without credentials; migrations require a valid URL.
const databaseUrl = process.env.DATABASE_URL;
const datasource = databaseUrl ? new URL(databaseUrl) : undefined;
if (datasource) {
if (
!['postgres:', 'postgresql:'].includes(datasource.protocol) ||
(datasource.searchParams.has('schema') &&
datasource.searchParams.get('schema') !== 'forms')
) {
throw new Error('Prisma requires a PostgreSQL URL using the forms schema.');
}
datasource.searchParams.set('schema', 'forms');
}
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: { path: 'prisma/migrations' },
datasource: { url: datasource?.toString() ?? '' },
});