25 lines
608 B
JavaScript
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);
|
|
});
|