-
Notifications
You must be signed in to change notification settings - Fork 6
updated prisma with new prisma config #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
856c0b0
093d5b0
f0a3322
530cd32
a386af2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import dotenv from "dotenv"; | ||
| import path from "node:path"; | ||
| import { defineConfig,env } from "prisma/config"; | ||
|
|
||
| dotenv.config({ | ||
| path: "./.env", | ||
| }); | ||
|
|
||
| export default defineConfig({ | ||
| schema: path.join("prisma", "schema.prisma"), | ||
| migrations: { | ||
| path: path.join("prisma", "migrations"), | ||
| }, | ||
| datasource: { | ||
| url: env("DATABASE_URL"), | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,11 @@ | ||||||||||||||||||||||
| import { PrismaClient } from "../generated/prisma"; | ||||||||||||||||||||||
| import { PrismaPg } from "@prisma/adapter-pg"; | ||||||||||||||||||||||
| import { PrismaClient } from "../generated/prisma/client"; | ||||||||||||||||||||||
| export * from "../generated/prisma/client"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const prisma = new PrismaClient(); | ||||||||||||||||||||||
| const adapter = new PrismaPg({ | ||||||||||||||||||||||
| connectionString: process.env.DATABASE_URL, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
Comment on lines
+5
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add validation for The 🔎 Proposed fix to add validation+if (!process.env.DATABASE_URL) {
+ throw new Error("DATABASE_URL environment variable is not set");
+}
+
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL,
});Alternatively, use a more defensive approach with a type assertion: const adapter = new PrismaPg({
- connectionString: process.env.DATABASE_URL,
+ connectionString: process.env.DATABASE_URL as string,
});
+
+if (!process.env.DATABASE_URL) {
+ throw new Error("DATABASE_URL environment variable is not set");
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export { prisma }; | ||||||||||||||||||||||
| const prisma = new PrismaClient({ adapter }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default prisma; | ||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.