Prisma Init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { PrismaPg } from "@prisma/adapter-pg";
|
||||
import { PrismaClient } from "../src/generated/prisma/client.js";
|
||||
|
||||
const connectionString = process.env.DATABASE_URL;
|
||||
if (!connectionString) {
|
||||
throw new Error("DATABASE_URL is not set");
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient({
|
||||
adapter: new PrismaPg({ connectionString }),
|
||||
});
|
||||
|
||||
const PROFILE_ID = "00000000-0000-4000-8000-000000000001";
|
||||
|
||||
const profile = {
|
||||
name: "Whoami",
|
||||
description: "Seeded profile",
|
||||
};
|
||||
|
||||
async function main() {
|
||||
await prisma.profile.upsert({
|
||||
where: { id: PROFILE_ID },
|
||||
create: {
|
||||
id: PROFILE_ID,
|
||||
...profile,
|
||||
},
|
||||
update: profile,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await main();
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
Reference in New Issue
Block a user