mirror of
https://github.com/JetSprow/J-Board-Lite.git
synced 2026-05-01 01:14:10 +05:30
32 lines
766 B
TypeScript
32 lines
766 B
TypeScript
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());
|