-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprisma.config.ts
More file actions
33 lines (28 loc) · 866 Bytes
/
prisma.config.ts
File metadata and controls
33 lines (28 loc) · 866 Bytes
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
import { defineConfig } from 'prisma/config';
import path from 'node:path';
function resolveSchemaRelativeSqliteUrl(databaseUrl: string): string {
if (!databaseUrl.startsWith('file:')) {
return databaseUrl;
}
const urlWithoutPrefix = databaseUrl.slice('file:'.length);
if (urlWithoutPrefix === ':memory:') {
return ':memory:';
}
const [sqlitePath, query] = urlWithoutPrefix.split('?');
const absolutePath = path.isAbsolute(sqlitePath)
? sqlitePath
: path.resolve(process.cwd(), 'prisma', sqlitePath);
return `file:${absolutePath}${query ? `?${query}` : ''}`;
}
const databaseUrl = resolveSchemaRelativeSqliteUrl(
process.env.DATABASE_URL ?? 'file:./prisma/dev.db'
);
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations'
},
datasource: {
url: databaseUrl
}
});