This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user