snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
53
packages/shadcn/test/fixtures/frameworks/remix-indie-stack/prisma/seed.ts
vendored
Normal file
53
packages/shadcn/test/fixtures/frameworks/remix-indie-stack/prisma/seed.ts
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function seed() {
|
||||
const email = "rachel@remix.run";
|
||||
|
||||
// cleanup the existing database
|
||||
await prisma.user.delete({ where: { email } }).catch(() => {
|
||||
// no worries if it doesn't exist yet
|
||||
});
|
||||
|
||||
const hashedPassword = await bcrypt.hash("racheliscool", 10);
|
||||
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
email,
|
||||
password: {
|
||||
create: {
|
||||
hash: hashedPassword,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.note.create({
|
||||
data: {
|
||||
title: "My first note",
|
||||
body: "Hello, world!",
|
||||
userId: user.id,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.note.create({
|
||||
data: {
|
||||
title: "My second note",
|
||||
body: "Hello, world!",
|
||||
userId: user.id,
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Database has been seeded. 🌱`);
|
||||
}
|
||||
|
||||
seed()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user