Files
whoami-api/prisma/seed.ts
T
2026-09-21 16:28:16 +03:00

36 lines
702 B
TypeScript

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();
}