Files
andris-carservice/prisma/seed-auth.js
T
2026-07-20 21:17:12 +01:00

25 lines
608 B
JavaScript

const { PrismaClient } = require("@prisma/client");
const bcrypt = require("bcryptjs");
async function main() {
const prisma = new PrismaClient();
const existing = await prisma.user.findUnique({ where: { username: "admin" } });
if (!existing) {
const hash = await bcrypt.hash("password", 10);
await prisma.user.create({
data: { username: "admin", password: hash },
});
console.log("Created default user: admin / password");
} else {
console.log("User already exists");
}
await prisma.$disconnect();
}
main().catch((e) => {
console.error(e);
process.exit(1);
});