Files
clube67_newwhats.local/newwhats.clube67.com/newwhats.local/backend/prisma/seed.ts
T
VPS 4 Deploy Agent 2f8c04a0a7
continuous-integration/webhook Falha no deploy de clube67_newwhats.local (VPS 4)
chore(ops): restore all source files in newwhats.clube67.com
2026-05-18 03:28:29 +02:00

46 lines
1.1 KiB
TypeScript

import { PrismaClient } from '@prisma/client'
import bcrypt from 'bcryptjs'
const prisma = new PrismaClient()
async function main() {
const ROUNDS = 10
const users = [
{
name: 'Usuário Padrão',
email: 'user@user.com',
password: '12345678',
role: 'USER' as const,
},
{
name: 'Admin',
email: 'ruibto@gmail.com',
password: 'Rc362514',
role: 'ADMIN' as const,
},
]
for (const u of users) {
const passwordHash = await bcrypt.hash(u.password, ROUNDS)
const existing = await prisma.user.findUnique({ where: { email: u.email } })
if (existing) {
await prisma.user.update({
where: { email: u.email },
data: { passwordHash, name: u.name, role: u.role },
})
console.log(`✅ Atualizado: ${u.email}`)
} else {
await prisma.user.create({
data: { name: u.name, email: u.email, passwordHash, role: u.role },
})
console.log(`✅ Criado: ${u.email} (${u.role})`)
}
}
}
main()
.catch((e) => { console.error(e); process.exit(1) })
.finally(() => prisma.$disconnect())