mirror of
https://github.com/JetSprow/J-Board-Lite.git
synced 2026-05-01 01:14:10 +05:30
Initial commit
This commit is contained in:
31
prisma/seed.ts
Normal file
31
prisma/seed.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import "dotenv/config";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaPg } from "@prisma/adapter-pg";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
|
||||
const prisma = new PrismaClient({ adapter });
|
||||
|
||||
async function main() {
|
||||
const hashedPassword = await bcrypt.hash("admin123", 12);
|
||||
|
||||
await prisma.user.upsert({
|
||||
where: { email: "admin@jboard.local" },
|
||||
update: {},
|
||||
create: {
|
||||
email: "admin@jboard.local",
|
||||
password: hashedPassword,
|
||||
name: "Admin",
|
||||
role: "ADMIN",
|
||||
},
|
||||
});
|
||||
|
||||
console.log("Seed completed: admin@jboard.local / admin123");
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user